问题描述
当我尝试使用命令 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 管理器中的一些包.会不会是这样?
Why does this happen? It used to work earlier the only thing I remember I changed is some packages from the SDK Manager. Could it be that?
推荐答案
gulp-sourcemaps 2.1.0,最近发布.这是 GitHub 上的一个问题:https://github.com/floridoo/gulp-源映射/问题/238.我相信它应该很快就会修复,同时您可以将其降级到2.0.x或1.7.x.
It is a bug in gulp-sourcemaps 2.1.0, which has been recently released. Here is an issue for it on GitHub: https://github.com/floridoo/gulp-sourcemaps/issues/238. I believe it should be fixed soon, meanwhile you can downgrade it to 2.0.x or 1.7.x.
更新:感谢 这个 GitHub 评论通过以下步骤使其工作:
Update: Thanks to this GitHub comment I was able to make it work with the following steps:
$ mkdir MyProject
$ cd MyProject
$ npm i [email protected]
$ cd ..
$ react-native init MyProject # answer yes
这篇关于出现错误:尝试初始化本机应用程序时找不到模块“./src/init"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!