鍍金池/ 問答/Linux/ 如何根除npm報錯 operation not permitted, scan

如何根除npm報錯 operation not permitted, scandir "xxx"

環(huán)境

  • windows 7 操作系統(tǒng)
  • npm 5.5.1

業(yè)務背景

通過npm安裝和刪除包的時候
項目是放在桌面上的,即系統(tǒng)盤里面
經常會報這個錯誤

npm install --save-dev file-loader
// 不僅僅是這個包,很多包都會報錯,而有些又不報錯
 Error: EPERM: operation not permitted, scandir '....
......`
 Please try running this command again as root/Administrator.

臨時應付的辦法

  1. git bash設置為以管理員身份啟動
  2. npm cache clean -force
  3. 刪除用戶目錄下的npm-cache文件夾
  4. 然后重新安裝就可以了

問題

通過什么辦法可以根除這個問題呢
每次安裝包都要刪除緩存文件真的很煩啊

回答
編輯回答
茍活

你以管理員身份運行git bash,把這個目錄刪掉,然后再以正常身份運行git bash,以后就不會有問題了

2017年1月17日 03:54