vue-cli npm安裝phantomjs失敗


有時候在使用vue-cli的時候會出現類似下面的錯誤:

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "D:\Programs\nodejs\node.exe" "D:\Programs\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "phantomjs-prebuilt"
npm ERR! node v7.8.0
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1

npm ERR! phantomjs-prebuilt@2.1.14 install: node install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs-prebuilt@2.1.14 install script 'node install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the phantomjs-prebuilt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs phantomjs-prebuilt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls phantomjs-prebuilt
npm ERR! There is likely additional logging output above.

主要的原因是因為有牆,訪問太慢,導致npm鏈接超時,官方原話在這里Error: connect ETIMEDOUT

解決方法:

方法1.開代理,這個就不講啦,網上一大堆

方法2.使用cnpm命令

 #卸載安裝失敗的phantomjs-prebuilt
 npm uninstall phantomjs-prebuilt --save-dev
 cnpm  install

方法3.使用以下命令進行安裝:

npm install phantomjs-prebuilt@2.1.14 --ignore-scripts

這種方法來自Stackoverflow


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM