解決vue項目Error:Cannot find module‘xxx’類報錯問題
vue項目Error:Cannot find module‘xxx’類報錯
現(xiàn)發(fā)現(xiàn)只要是報錯 Error: Cannot find module ‘xxx’(例如 Error: Cannot find module ‘webpack’)這類的問題都可以用下面的方法解決。
報錯內(nèi)容如下
運行 npm install 沒問題,運行 npm run serve 就會報錯:
Error: Cannot find module ‘webpack’
解決方案
- 到項目文件夾下,刪除 node_modules 文件和 package-lock.json 文件。注意不是package.json(如果刪不掉,看下項目是不是打開了,關了再試試)
- 在項目下運行npm install
- 繼續(xù)運行npm run dev(這里不一定是dev,要根據(jù)自己實際項目中的配置來,就是啟動項目就行)
后面如果報需要安裝什么插件,再繼續(xù)安裝插件,重啟即可。
一定要刪除 package-lock.json 不然沒有效果!!
安裝依賴時錯誤:fatal: repository ‘https://github.com/nhn/raphael.git/’ not found
vue項目 npm i 安裝依賴失敗
npm ERR! Error while executing:
npm ERR! d:\Git\cmd\git.EXE ls-remote -h -t https://github.com/nhn/raphael.git
npm ERR! fatal: unable to access 'https://github.com/nhn/raphael.git/': OpenSSL SSL_read: Connection was reset, errno 10054
npm ERR!
npm ERR! exited with error code: 128npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\glq\AppData\Roaming\npm-cache\_logs\2021-08-05T01_57_51_837Z-debug.log
解決方案 1:
當前網(wǎng)絡無法訪問 github.com ,建議切換為手機熱點網(wǎng)絡。
解決方案 2:
- 1、配置淘寶鏡像
npm install --registry=https://registry.npm.taobao.org //單次使用 npm config set registry https://registry.npm.taobao.org //永遠使用
配置完成后檢驗是否成功:
npm config get registry //或者下一行 npm info express//或者上一行
- 2、再次安裝
npm i
注意:
如果想還原 npm 倉庫地址,只需再把地址配置成 npm 鏡像就可以了
npm config set registry https://registry.npmjs.org/
總結
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
vue computed計算屬性顯示undefined的解決
這篇文章主要介紹了vue computed計算屬性顯示undefined的解決方案,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-11-11require.js 加載 vue組件 r.js 合并壓縮的實例
這篇文章主要介紹了require.js 加載 vue組件 r.js 合并壓縮的相關資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-10-10