如何刪除node_modules重新安裝的方法步驟
阿新 • • 發佈:2021-09-15
目錄
- 第一步:在專案需要安裝 node_modules 的目錄下
- 第二步:先安裝 rimraf 工具
- 第三步:刪除 node_modules 包和 package-lock.on 檔案
- 第四步:清除快取
- 第五步:重新安裝依賴包
- 第六步:重啟專案
我們在開發專案的時候,每次安裝的 node 包會出現版本和專案所需要的版本不一致的問題。因此需要刪除 node 包,重新安裝它,很多小夥伴只是把他給手動刪除了,但是卻沒有刪除包的快取,因此在啟動專案的時候還是會報錯~
接篇文章就是簡單直接明瞭的告訴大家詳細操作步驟
針對於 Windows 系統
第一步:在專案需要安裝 node_modules 的目錄下
第二步:先安裝 rimraf 工具
npm iwww.cppcns.comnstall -g rimraf
第三步:刪除 node_modules 包和 package-lock.json 檔案
rimraf node_modules rimraf package-lock.json
http://www.cppcns.com注意:node_modules 和package-lock.json 都需要刪除,如果只刪除 node_modules 也是不可以的。
第四步:清除快取
npm cache clear --force
第五步:重新安裝依賴包
安裝完成會自動生成 package-lock.json 檔案
npm config set registry [https://registry.npm.taobao.org] npm install
第六步:重啟專案
到此這篇關於刪除node_modules重新安裝的方法步驟的文章就介紹到這了,更多相關刪http://www.cppcns.com除node_modules重新安裝內容請搜尋我們以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援我們!