安裝node及vue專案的啟動

云岛夜川川發表於2024-10-24

1、ubuntu 安裝npm

sudo apt install nodejs npm

2、設定包下載源

npm config set registry https://registry.npmmirror.com/

3.安裝包及執行

npm install
安裝成功後會生成一個node_moudels目錄

執行:
npm run serve

4、常見報錯及解決方式

(1)old lockfile報錯

npm WARN old lockfile
npm WARN deprecated axios@0.19.2: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
npm ERR! Cannot read property 'insert' of undefined

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2024-10-23T14_29_13_268Z-debug-0.log

解決:

rm -rf node_modules package-lock.json
npm install

(2)下載源可能報錯無認證:

npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/yorkie/download/yorkie-2.0.0.tgz failed, reason: certificate has expired

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2024-10-23T14_25_10_918Z-debug-0.log

j解決:禁用ssl:

npm config set strict-ssl false

相關文章