在将react本机项目升级到0.21.0之后,我在运行react时遇到了这个错误:
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
我尝试过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" } }
我怀疑启动一个新的项目会解决这个问题,因为它显然与依赖冲突有关。
发布于 2016-03-06 19:42:56
最后我用这个脚本解决了这个问题:
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);
},
};发布于 2016-03-06 19:20:24
你试过jrichardlai于1月22日发表评论留下的这个技巧了吗?
对于仍然面临此问题的人,临时的方法可以是在package.json中添加fbjs作为依赖项,然后在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 "{}" \;https://stackoverflow.com/questions/35831234
复制相似问题