当我尝试使用命令安装 react native 时 react-native init ProjectName
我得到以下信息:
This will walk you through creating a new React Native project in C:\Users\Xegano\Documents\ProjectName
Installing react-native package from npm...
Setting up new React Native app in C:\Users\Xegano\Documents\ProjectName
module.js:457
throw err;
^
Error: Cannot find module './src/init'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Xegano\Documents\ProjectName\node_modules\gulp-sourcemaps\index.js:4:9)
at Module._compile (module.js:556:32)
at Module._extensions..js (module.js:565:10)
at Object.require.extensions.(anonymous function) [as .js] (C:\Users\Xegano\Documents\ProjectName\node_modules\babel-register\lib\node.js:152:7)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
为什么会发生这种情况?它以前可以工作,我记得我改变的唯一一件事是 SDK 管理器中的一些包。会是这样吗?
最佳答案
实际上它在我的情况下有效,但我需要将 gulp-sourcemaps 降级到 1.7 版
$ cd MyProject
$ rm -rf node_modules/gulp-sourcemaps
$ npm install gulp-sourcemaps@1.7
$ cd ..
$ react-native init MyProject
关于npm - 获取错误 : Cannot find module './src/init' when trying to initialize a react native app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40030716/