Skip to content

24jieqi/icon

Repository files navigation

🎨 SVG Icons.

React

install size

React Native

install size

Taro

install size

开发过程中遇见的一些问题

ts-node

node-fetch

package.json

{ "type": "module" }

tsconfig.json

{
  "ts-node": {
    "esm": true
  }
}

node-fetch 采用 ES Module 写法,需要项目里面也一起用,要么用最新的 2.x 版本。

import module

一般情况内部引入模块可以忽略后缀名,但是 "type": "module" 需要手动指定为 .js

Relative import paths need full extensions (we have to write import "./foo.js" instead of import "./foo").

ES Module

__dirname 和 __filename

import path from 'path'
import { fileURLToPath } from 'url'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)