一個 Vue 項目從一台電腦上傳到 github 上之后,再另外一台電腦上 git clone
。並使用 npm run dev
或 npm run start
發生以下報錯的解決方法。

報錯原因
缺少 node_modules
里面的依賴。在項目目錄下使用 npm install
然后再 npm run dev
。
如果在這一步當中, npm install
執行的過程中,處於一直卡頓的狀態。說明網絡狀況不佳。建議使用 cnpm
淘寶源。
淘寶源
使用 cnpm -v
查看是否已經安裝 cnpm
。如果沒有,使用 npm install cnpm -g --registry=https://registry.npm.taobao.org
命令安裝。然后將上面 npm
的步驟命令改成 cnpm
即可。