快速刪除node_modules文件夾
前端開發(fā)過程中,經(jīng)常會遇到npm操作問題,有時候不得不需要刪除node_modules目錄下所有的文件,然后重新npm install
npm cache clean --force
rm -rf node_modules
#rm -rf .umi
npm install
- 清除緩存:運行
npm cache clean --force
命令來清除 npm 緩存。然后運行 npm install 命令重新安裝依賴項。 - 刪除 node_modules 目錄:手動刪除項目目錄下的 node_modules 目錄,并運行 npm install 命令重新安裝依賴項。
node_modules 文件夾中包含了大量 node 需要的依賴包,如果直接刪除的話,非常耗時。 我們可以通過以下方式快速刪除node_modules
PowerShell命令快速刪除
PowerShell命令快速刪除node_modules文件夾
Remove-item -Force -Recurse node_modules
#Remove-item -Force -Recurse .umi
使用npm提供的命令刪除node_modules
執(zhí)行rm-rf node_modules,報錯:“rm不是內(nèi)部命令“ 時候,我們可以使用npm提供的命令刪除node_modules
npm為我們提供了快速刪除node_modules的命令,即使用npm自帶的“rimraf”包。它是一個跨平臺的rm –rf命令。文章來源:http://www.zghlxwxcb.cn/news/detail-783362.html
方法:文章來源地址http://www.zghlxwxcb.cn/news/detail-783362.html
cnpm install rimraf -g
rimraf ./node_modules
到了這里,關(guān)于快速刪除node_modules文件夾的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!