1. 程式人生 > 其它 >使用--ignore-scripts解決npm/yarn安裝依賴失敗問題

使用--ignore-scripts解決npm/yarn安裝依賴失敗問題

技術標籤:nodejsignore-script依賴安裝npm errorcode ELIFECYCLE

npm安裝報錯問題

最近使用npm安裝依賴頻繁遇到安裝失敗的問題,報錯如下

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @3.0.5 preinstall: `node ./scripts/checkYarn.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @3.0.5 preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

解決方案

  • 安裝命令使用
npm i --ignore-scripts
// or
yarn --ignore-scripts
  • 清除公司私服的temp目錄
    • 一般人都不會這麼幹

原因探究

公司私服代理阻止了依賴的正常安裝,或者是你本地的指令碼檔案異常導致了依賴安裝失敗(上方報錯資訊中的./scripts/checkYarn.js

參考

https://stackoverflow.com/questions/40992231/failed-at-the-phantomjs-prebuilt2-1-13-install-script-node-install-js

END