我在安装React Native CLI时遇到问题
当我运行react-native init
或任何其他cli方法时
internal/modules/cjs/loader.js:296
throw err;
^
Error: Cannot find module '/usr/local/lib/node_modules/react-native-cli/node_modules/prompt/lib/prompt'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:288:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:515:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:759:27)
at Function.Module._load (internal/modules/cjs/loader.js:677:27)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Object.<anonymous> (/usr/local/lib/node_modules/react-native-cli/index.js:43:14)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32) {
code: 'MODULE_NOT_FOUND',
path: '/usr/local/lib/node_modules/react-native-cli/node_modules/prompt/package.json',
requestPath: 'prompt'
}
使用npm install -g react-native-cli
删除并重新安装,但是没有运气。
节点版本v12.10.0, npm版本6.10.3
答案 0 :(得分:0)
此问题已通过完全删除Node并使用自制软件重新安装来解决
答案 1 :(得分:0)
我已解决,方法是删除node
并删除此文件夹/usr/local/lib/node_modules/react-native-cli/node_modules/
并重新安装node