无法解析模块“@expo/vector-icons”
unable to resolve module `@expo/vector-icons`
我不确定为什么会收到此错误:
Unable to resolve module `@expo/vector-icons` from `...(directory path here)...` : Module does not exist in the module pack
我已经尝试了其他 forums/sites 上建议的以下内容:
- 清除守望者手表
- 正在删除 node_modules 文件夹
- 重置打包程序缓存
package.json
{
"name": "app name",
"version": "0.0.0",
"description": "Hello Expo!",
"author": null,
"private": true,
"main": "node_modules/expo/AppEntry.js",
"dependencies": {
"babel-plugin-module-resolver": "^2.5.0",
"babel-preset-expo": "^4.0.0",
"expo": "^21.0.0",
"firebase": "^4.5.1",
"geofire": "^4.1.2",
"moment": "^2.19.1",
"react": "16.0.0-alpha.12",
"react-native": "https://github.com/expo/react-native/archive/sdk-21.0.2.tar.gz",
"react-navigation": "^1.0.0-beta.13"
}
}
但仍然没有,仍然出现此错误
听起来 vector-icons
是您应该在 package.json
(https://www.npmjs.com/package/@expo/vector-icons)
中声明的另一个库
我通过这个命令解决了这个问题npm install @expo/vector-icons --save
我运行遇到了同样的问题。这是 babel-preset-expo。卸载它并执行以下操作
npm i metro-react-native-babel-preset --save-dev
删除 babel.config.json 并创建一个名为 .babelrc
的新文件
然后指定预设
{
"presets": ["module:metro-react-native-babel-preset"]
}
命令 npm install @expo/vector-icons --save
完成任务!
我出现此错误的原因是,当我将 useState
放入我的应用程序时,VS Code 自动从 react-native-vector-icons/node_modules/@types/react
导入它,而不是从“react”
我不确定为什么会收到此错误:
Unable to resolve module `@expo/vector-icons` from `...(directory path here)...` : Module does not exist in the module pack
我已经尝试了其他 forums/sites 上建议的以下内容:
- 清除守望者手表
- 正在删除 node_modules 文件夹
- 重置打包程序缓存
package.json
{
"name": "app name",
"version": "0.0.0",
"description": "Hello Expo!",
"author": null,
"private": true,
"main": "node_modules/expo/AppEntry.js",
"dependencies": {
"babel-plugin-module-resolver": "^2.5.0",
"babel-preset-expo": "^4.0.0",
"expo": "^21.0.0",
"firebase": "^4.5.1",
"geofire": "^4.1.2",
"moment": "^2.19.1",
"react": "16.0.0-alpha.12",
"react-native": "https://github.com/expo/react-native/archive/sdk-21.0.2.tar.gz",
"react-navigation": "^1.0.0-beta.13"
}
}
但仍然没有,仍然出现此错误
听起来 vector-icons
是您应该在 package.json
(https://www.npmjs.com/package/@expo/vector-icons)
我通过这个命令解决了这个问题npm install @expo/vector-icons --save
我运行遇到了同样的问题。这是 babel-preset-expo。卸载它并执行以下操作
npm i metro-react-native-babel-preset --save-dev
删除 babel.config.json 并创建一个名为 .babelrc
的新文件然后指定预设
{
"presets": ["module:metro-react-native-babel-preset"]
}
命令 npm install @expo/vector-icons --save
完成任务!
我出现此错误的原因是,当我将 useState
放入我的应用程序时,VS Code 自动从 react-native-vector-icons/node_modules/@types/react
导入它,而不是从“react”