将我的react-native项目升级到0.21.0
后,我在运行react-packager时遇到了这个错误:
Failed to build DependencyGraph: Naming collision detected: /Users/xxxxxxxx/node_modules/react/node_modules/fbjs/lib/warning.js collides with /Users/xxxxxxx/node_modules/react-native/node_modules/fbjs/lib/warning.js
我已尝试deleting all instances of fbjs
并清理缓存,并使用npm3
安装我的依赖项,但这会导致模块解决错误:
Unable to resolve module keyMirror from /Users/xxxxxxx/node_modules/react-native/Libraries/Utilities/MessageQueue.js: Unable to find this module in its module map or any of the node_modules directories under /Users/node_modules/keyMirror and its parent directories
它建议重置缓存并重新安装node_modules,但这不能解决问题。
我的package.json
:
{
"name": "myproject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start"
},
"dependencies": {
"@exponent/react-native-navigator": "^0.4.2",
"flux": "^2.1.1",
"react-native": "^0.21.0",
"react-native-action-button": "^1.1.2",
"react-native-audio": "^0.3.2",
"react-native-blur": "^0.7.7",
"react-native-image-picker": "^0.10.0",
"react-native-lightbox": "^0.5.0",
"react-native-search-bar": "^2.7.0",
"react-native-vector-icons": "^1.0.4"
},
"devDependencies": {
"babel-eslint": "^5.0.0",
"eslint": "^2.2.0",
"eslint-plugin-react": "^3.16.1"
}
}
我怀疑启动一个新项目会解决这个问题,因为它与依赖冲突明显相关。
答案 0 :(得分:1)
我最终用这个脚本解决了这个问题:
https://github.com/facebook/react-native/issues/5467#issuecomment-187873411
'use strict';
const blacklist = require('react-native/packager/blacklist');
var config = [
/{root folder name}\/node_modules\/.+\/node_modules\/fbjs\/.*/
]
module.exports = {
getBlacklistRE() {
return blacklist('', config);
},
};
答案 1 :(得分:0)
您是否尝试过jrichardlai commented on Jan 22
留下的此提示对于仍然面临此问题的人来说,临时可以添加 fbjs作为package.json中的依赖项,然后运行一个脚本 postinstall删除额外的fbjs https://gist.github.com/jrichardlai/a6a36352e1b98eb2946a
指向这个要点的链接......
find ./node_modules -type d -name fbjs -and -not -path ./node_modules/fbjs -print -exec rm -rf "{}" \;