执行npm install --save react-navigation后,项目无法运行。

17-06-28 13:10 字数 1753 阅读 6581 已编辑

报错信息如下

error: bundling: UnableToResolveError: Unable to resolve module `react` from `/Users/luzhuang/develop/shiqidu/index.ios.js`: Module does not exist in the module map or in these directories:
  /Users/luzhuang/develop/shiqidu/node_modules

This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
  1. Clear watchman watches: `watchman watch-del-all`.
  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
  3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.
    at ResolutionRequest._resolveNodeDependency (/Users/luzhuang/develop/shiqidu/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:394:11)
    at tryResolveSync (/Users/luzhuang/develop/shiqidu/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:136:20)
    at tryResolveSync (/Users/luzhuang/develop/shiqidu/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:66:12)
    at ResolutionRequest.resolveDependency (/Users/luzhuang/develop/shiqidu/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:134:22)
    at dependencyNames.map.name (/Users/luzhuang/develop/shiqidu/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:145:59)
    at Array.map (native)
    at ResolutionRequest.resolveModuleDependencies (/Users/luzhuang/develop/shiqidu/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:145:42)
    at Promise.resolve.then (/Users/luzhuang/develop/shiqidu/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:169:21)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:169:7)

原因

可能是npm5有bug

解决方法

使用yarn代替npm install

yard add代替npm install --save

yarn add react-navigation
0人点赞>
关注 收藏 改进 举报
0 条评论
排序方式 时间 投票
快来抢占一楼吧
请登录后发表评论
站长 @ 十七度
文章
380
粉丝
23
喜欢
191
收藏
31
排名 : 1
访问 : 128.23万
私信