npm ERR!运行npm install时的代码ELIFECYCLE

时间:2018-07-18 01:24:44

标签: reactjs npm

每次我在样板项目上运行npm install时,都会出现此错误:

ERROR in multi react-color moment ag-grid ag-grid-react es6-promise react-dom-factories react-spinners sortablejs
Module not found: Error: Can't resolve 'react-spinners' in 'C:\Code\react-boilerplate'
 @ multi react-color moment ag-grid ag-grid-react es6-promise react-dom-factories react-spinners sortablejs vendor[6]

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @myapp/app@0.0.1 build: `webpack --config ./webpack.prod.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @myapp/app@0.0.1 build 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!     D:\Users\johndoe\AppData\Roaming\npm-cache\_logs\2018-07-18T01_29_52_633Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @myapp/app@0.0.1 prepare: `npm run build && npm run build:dev`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @myapp/app@0.0.1 prepare 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!     D:\Users\johndoe\AppData\Roaming\npm-cache\_logs\2018-07-18T01_29_52_874Z-debug.log

我该如何解决?

编辑:

运行npm install -S react-spinners && npm install后,得到以下信息:

ERROR in multi react-color moment ag-grid ag-grid-react es6-promise react-dom-factories react-spinners sortablejs
Module not found: Error: Can't resolve 'sortablejs' in 'C:\Code\react-boilerplate'
 @ multi react-color moment ag-grid ag-grid-react es6-promise react-dom-factories react-spinners sortablejs vendor[7]

1 个答案:

答案 0 :(得分:1)

这些错误告诉您您尚未安装react-spinnerssortablejs。您可以安装它们并将它们添加到您的dependencies中,它将起作用:

npm i -S react-spinners sortablejs && npm install

可能是某些其他软件包将react-spinnerssortablejs设置为peerDependecies,或者您可能早先安装了这些软件包而没有将它们添加到dependencies中,这会给如果您删除node_modules并重新安装,则会出现错误。