加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

npm – 获取错误:尝试初始化react本机应用程序时找不到模块’./

发布时间:2020-12-15 16:18:09 所属栏目:百科 来源:网络整理
导读:当我尝试使用命令react-native init ProjectName安装react native时 我得到以下内容: This will walk you through creating a new React Native project in C:UsersXeganoDocumentsProjectNameInstalling react-native package from npm...Setting up n
当我尝试使用命令react-native init ProjectName安装react native时

我得到以下内容:

This will walk you through creating a new React Native project in C:UsersXeganoDocumentsProjectName
Installing react-native package from npm...
Setting up new React Native app in C:UsersXeganoDocumentsProjectName
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:UsersXeganoDocumentsProjectNamenode_modulesgulp-sourcemapsindex.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:UsersXeganoDocumentsProjectNamenode_modulesbabel-registerlibnode.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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读