npm更新包以後啓動項目報錯

問題一

internal/modules/cjs/loader.js:626
    throw err;
    ^

Error: Cannot find module 'chalk'
Require stack:
- /Users/chelsea/Documents/code/react-template/server/logger.js
- /Users/chelsea/Documents/code/react-template/server/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:623:15)
    at Function.Module._load (internal/modules/cjs/loader.js:527:27)
    at Module.require (internal/modules/cjs/loader.js:681:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (/Users/chelsea/Documents/code/react-template/server/logger.js:3:15)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:681:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/chelsea/Documents/code/react-template/server/logger.js',
    '/Users/chelsea/Documents/code/react-template/server/index.js'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-template@3.1.0 start: `cross-env NODE_ENV=development node server`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the react-template@3.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/chelsea/.npm/_logs/2019-06-19T01_42_14_852Z-debug.log

解決方案

一、刪除package-lock.json這個文件,再啓動仍是沒有用node

二、清除緩存npm cache clear --force,再啓動仍是沒有用react

三、從新安裝這個模塊npm install chalk,再啓動 又報了其它新的一個錯webpack

四、綜合第三點考慮,就刪掉整個模塊包rm -rf node_modules,刪除package-lock.json,再清除緩存npm cache clear --force,而後從新安裝包npm installweb

最後運行起來了,但仍是報錯npm

ERROR in ./app/containers/ComponentLifecycle/Step/index.js
Module not found: Error: Can't resolve 'image-webpack-loader' in '/Users/chelsea/Documents/code/react-template'
 @ ./app/containers/ComponentLifecycle/Step/index.js 28:0-41 593:13-19
 @ ./app/containers/ComponentLifecycle/Step/Loadable.js
 @ ./app/routers/index.js
 @ ./app/layouts/PrimaryLayout/index.js
 @ ./app/containers/App/index.js
 @ ./app/app.js
 @ multi ./node_modules/react-app-polyfill/ie11.js webpack-hot-middleware/client?reload=true ./app/app.js

ERROR in ./app/containers/ComponentLifecycle/Step/index.js
Module not found: Error: Can't resolve 'image-webpack-loader' in '/Users/chelsea/Documents/code/react-template'
 @ ./app/containers/ComponentLifecycle/Step/index.js 27:0-41 564:13-19
 @ ./app/containers/ComponentLifecycle/Step/Loadable.js
 @ ./app/routers/index.js
 @ ./app/layouts/PrimaryLayout/index.js
 @ ./app/containers/App/index.js
 @ ./app/app.js
 @ multi ./node_modules/react-app-polyfill/ie11.js webpack-hot-middleware/client?reload=true ./app/app.js

ERROR in ./app/containers/ComponentLifecycle/Step/index.js
Module not found: Error: Can't resolve 'image-webpack-loader' in '/Users/chelsea/Documents/code/react-template'
 @ ./app/containers/ComponentLifecycle/Step/index.js 26:0-41 518:13-19
 @ ./app/containers/ComponentLifecycle/Step/Loadable.js
 @ ./app/routers/index.js
 @ ./app/layouts/PrimaryLayout/index.js
 @ ./app/containers/App/index.js
 @ ./app/app.js
 @ multi ./node_modules/react-app-polyfill/ie11.js webpack-hot-middleware/client?reload=true ./app/app.js

ERROR in ./app/containers/ComponentLifecycle/Step/index.js
Module not found: Error: Can't resolve 'image-webpack-loader' in '/Users/chelsea/Documents/code/react-template'
 @ ./app/containers/ComponentLifecycle/Step/index.js 25:0-41 454:13-19
 @ ./app/containers/ComponentLifecycle/Step/Loadable.js
 @ ./app/routers/index.js
 @ ./app/layouts/PrimaryLayout/index.js
 @ ./app/containers/App/index.js
 @ ./app/app.js
 @ multi ./node_modules/react-app-polyfill/ie11.js webpack-hot-middleware/client?reload=true ./app/app.js

ERROR in ./app/containers/ComponentLifecycle/Step/index.js
Module not found: Error: Can't resolve 'image-webpack-loader' in '/Users/chelsea/Documents/code/react-template'
 @ ./app/containers/ComponentLifecycle/Step/index.js 24:0-41 415:13-19
 @ ./app/containers/ComponentLifecycle/Step/Loadable.js
 @ ./app/routers/index.js
 @ ./app/layouts/PrimaryLayout/index.js
 @ ./app/containers/App/index.js
 @ ./app/app.js
 @ multi ./node_modules/react-app-polyfill/ie11.js webpack-hot-middleware/client?reload=true ./app/app.js

ERROR in ./app/containers/ComponentLifecycle/Step/index.js
Module not found: Error: Can't resolve 'image-webpack-loader' in '/Users/chelsea/Documents/code/react-template'
 @ ./app/containers/ComponentLifecycle/Step/index.js 23:0-41 371:13-19
 @ ./app/containers/ComponentLifecycle/Step/Loadable.js
 @ ./app/routers/index.js
 @ ./app/layouts/PrimaryLayout/index.js
 @ ./app/containers/App/index.js
 @ ./app/app.js
 @ multi ./node_modules/react-app-polyfill/ie11.js webpack-hot-middleware/client?reload=true ./app/app.js

最後改用yarn安裝模塊, 安裝了幾回。最後啓動yarn start終於沒有報錯了json

相關文章
相關標籤/搜索