折腾:
【未解决】把ReactJS-AdminLTE中的导航栏和标题栏集成到react-hot-boilerplate
期间,用:
npm run build
结果出错:
ERROR in ./node_modules/react/lib/ReactComponent.js Module not found: Error: Can’t resolve ‘fbjs/lib/warning’ in ‘/Users/crifan/dev/dev_root/daryun/Projects/xxxsourcecode/web/AdminManagement/reference/react-hot-boilerplate/react-hot-boilerplate/node_modules/react/lib’ @ ./node_modules/react/lib/ReactComponent.js 20:14-41 @ ./node_modules/react/lib/React.js @ ./node_modules/react/react.js @ ./src/index.js ERROR in ./node_modules/react/lib/ReactElement.js Module not found: Error: Can’t resolve ‘fbjs/lib/warning’ in ‘/Users/crifan/dev/dev_root/daryun/Projects/xxxAdminManagement/reference/react-hot-boilerplate/react-hot-boilerplate/node_modules/react/lib’ @ ./node_modules/react/lib/ReactElement.js 17:14-41 @ ./node_modules/react/lib/React.js @ ./node_modules/react/react.js @ ./src/index.js ERROR in ./node_modules/react/lib/traverseAllChildren.js Module not found: Error: Can’t resolve ‘fbjs/lib/warning’ in ‘/Users/crifan/dev/dev_root/daryun/Projects/xxx/AdminManagement/reference/react-hot-boilerplate/react-hot-boilerplate/node_modules/react/lib’ @ ./node_modules/react/lib/traverseAllChildren.js 21:14-41 @ ./node_modules/react/lib/ReactChildren.js @ ./node_modules/react/lib/React.js @ ./node_modules/react/react.js @ ./src/index.js |
Module not found Error Can’t resolve fbjs/lib/warning
难道是对应的库没有安装?
reactjs – "module not found : Error: Cannot resolve module ‘react/lib/ReactMount’ " – Stack Overflow
去项目中搜了下,发现了:
prop-types
react
react-dom
都依赖于,用到了fbjs
看来是没有安装,去安装试试
➜ react-hot-boilerplate git:(master) ✗ npm install fbjs –save-dev npm WARN [email protected] requires a peer of webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none was installed. npm WARN [email protected] requires a peer of react@^15.6.1 but none was installed. added 2 packages in 12.144s |
然后同时看看:
fbjs
是个什么库
facebook/fbjs: A collection of utility libraries used by other Facebook JS projects.
“A collection of utility libraries used by other Facebook JS projects.”
unknown module fbjs/lib/invariant · Issue #1026 · aksonov/react-native-router-flux
是个facebook出的库,包含了一堆工具库,用于其他很多facebook的JS的项目的。
难怪此处的facebook出的react,react-dom依赖这个fbjs
安装好之后,可以在:
/react-hot-boilerplate/package.json
"devDependencies": { 。。。 "fbjs": "^0.8.14", |
中看到fbjs:
然后再去npm run build就没了该错误了。
【总结】
此处npm run build通过webpack去打包出错:
Module not found: Error: Can’t resolve ‘fbjs/lib/warning’ in
原因是:
缺少了这个fbjs库。
但是之前没有报错的原因是:
此处是刚引入了新的其他代码,内部用到了fbjs这个库。
说明:fbjs是啥:
这个是库是facebook出的,内部包含了一堆工具类,被用于其他很多Facebook的JS项目中。
此处prop-types,react,react-dom都依赖于fbjs这个库。
解决办法是:
安装这个库:
npm install fbjs –save-dev |
即可。
转载请注明:在路上 » 【已解决】webpack编译出错:Module not found Error Can’t resolve fbjs/lib/warning