当我尝试使用命令react-native init ProjectName安装react native时 我得到以下内容: This will walk you through creating a new React Native project in C:\Users\Xegano\Documents\ProjectNameInstalling react-native package from
我得到以下内容:
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 Manager中的一些软件包.可能是那个吗?
这是最近发布的 gulp-sourcemaps 2.1.0中的一个错误.这是GitHub上的一个问题: https://github.com/floridoo/gulp-sourcemaps/issues/238.我相信它应该很快修复,同时你可以将它降级到2.0.x或1.7.x.更新:感谢this GitHub comment我能够通过以下步骤使其工作:
$mkdir MyProject $cd MyProject $npm i gulp-sourcemaps@1.7 $cd .. $react-native init MyProject # answer yes