npm install 或 npm install webpack --save-dev 报错

在centos7下执行 npm install 和 npm install webpack --save-dev 都报了如下错,很郁闷,搞了好久。

npm WARN [email protected] requires a peer of ajv@>=5.0.0 but none is
installed. You must install peer dependencies yourself.

npm ERR! code ENOENT npm ERR! syscall access npm ERR! path
/yonyou/uat-workspace/occ-project/hhocc/occ-portal-static/node_modules/[email protected]@accepts/node_modules/mime-types
npm ERR! errno -2 npm ERR! enoent ENOENT: no such file or directory,
access
‘/yonyou/uat-workspace/occ-project/hhocc/occ-portal-static/node_modules/[email protected]@accepts/node_modules/mime-types’
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in: npm ERR!
/root/.npm/_logs/2020-04-15T03_37_37_044Z-debug.log
[root@ecs-639d-0002 occ-portal-static]# npm run webpack npm ERR!
missing script: webpack

npm ERR! A complete log of this run can be found in: npm ERR!
/root/.npm/_logs/2020-04-15T03_38_08_854Z-debug.log

最终解决是使用 rm -rf 命令 删除项目下的 node_modules 文件
即:rm -rf node_modules/
如图:npm install 或 npm install webpack --save-dev 报错_第1张图片
再执行: npm install webpack --save-dev,如图:
在这里插入图片描述

执行成功后再执行:npm install,如图:
npm install 或 npm install webpack --save-dev 报错_第2张图片

你可能感兴趣的:(其他)