React本机打包程序在节点6.5上失败

时间:2016-09-01 23:43:41

标签: react-native

这是以前的工作。但是,自从我从节点4.6升级到6.5后,当我执行npm start时,我最终得到以下错误

Failed to build DependencyGraph: @providesModule naming collision:
  Duplicate module name: String.prototype.es6
  Paths: ...../node_modules/react-native/packager/react-packager/src/Resolver/polyfills/String.prototype.es6.js collides with ...../app/MallJell/nd/react-native/packager/react-packager/src/Resolver/polyfills/String.prototype.es6.js

This error is caused by a @providesModule declaration with the same name across two different files.
Error: @providesModule naming collision:
  Duplicate module name: String.prototype.es6
  Paths: ....../react-native/packager/react-packager/src/Resolver/polyfills/String.prototype.es6.js collides with ..../react-packager/src/Resolver/polyfills/String.prototype.es6.js

This error is caused by a @providesModule declaration with the same name across two different files.
    at HasteMap._updateHasteMap (..../node_modules/react-native/packager/react-packager/src/node-haste/DependencyGraph/HasteMap.js:155:13)
    at module.getName.then.name (.....node_modules/react-native/packager/react-packager/src/node-haste/DependencyGraph/HasteMap.js:115:31)

2 个答案:

答案 0 :(得分:1)

我只是在这里找到适合您的答案,以便其他人可以看到。

删除node_modules文件夹

rm -rf node_modules/

然后清理npm缓存并重新安装模块

npm cache clean && npm install

然后再次运行打包器

npm start

答案 1 :(得分:-1)

我通过修改“packag.json”的代码来解决这个问题。然后重新安装nodemodules。

在:

"scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
},


"scripts": {
       "start": "react-native start"
},