使用--ignore-scripts解决npm/yarn安装依赖失败问题

npm安装报错问题一:

最近使用npm安装依赖频繁遇到安装失败的问题,报错如下

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fibers@4.0.3 install: `node build.js || nodejs build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fibers@4.0.3 install 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:Program FilesJavaScript
odejs-14.17.6
ode_cache\_logs2021-09-29T04_09_38_618Z-debug.log

解决方案

 npm install fibers@4.0.3 --ignore-scripts

清除公司私服的temp目录
一般人都不会这么干

原因探究
公司私服代理阻止了依赖的正常安装,或者是你本地的脚本文件异常导致了依赖安装失败(上方报错信息中的./scripts/checkYarn.js)

npm安装报错问题二:

Error:npm ERR! Failed at the bcrypt@5.0.0 install script.

npm ERR! code ELIFECYCLE
npm ERR! errno 9009
npm ERR! bcrypt@5.0.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 9009
npm ERR!
npm ERR! Failed at the bcrypt@5.0.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Solution1

Reason for Error : Node maybe can’t able to find the Python path on your system

step: 1 Rum command prompt as administrator step 2 Install the package

  npm install --global --production windows-build-tools

It may take some while, keep patient

step 3 Now install

npm install node-gyp

Last step Now you are ready to Go

npm install bcrypt

 

  • 安装命令使用下面的命令 XXX换成在里面报错无法正常安装的插件名称
npm i XXXX --ignore-scripts
// or
yarn XXXX --ignore-scripts
声明 欢迎转载,但请保留文章原始出处:) 博客园:https://www.cnblogs.com/chenxiaomeng/ 如出现转载未声明 将追究法律责任~谢谢合作
原文地址:https://www.cnblogs.com/chenxiaomeng/p/15352880.html