Windows環境下npm install 報錯: operation not permitted, rename的解決方案_node.js

來源:互聯網
上載者:User

前言

最近發現了一個問題,運行 npm install 命令安裝依賴包,在 Mac 上的 Vagrant 裝的虛擬機器上沒問題,在阿里雲 CentOS 上也沒問題,但是在 Windows 環境同樣是 Vagrant 裝的環境相同的虛擬機器上就是不成功,報錯如下:

npm ERR! Error: EPERM: operation not permitted, rename ‘/usr/share/nginx/html/tanteng.me/node_modules/duplexify' -> ‘/usr/share/nginx/html/tanteng.me/node_modules/.duplexify.DELETE'

之前遇到過 Windows 上 npm 安裝依賴出現 symbol 的錯誤,解決方案是 sudo npm install –no-bin-links,加後面的參數即可。

列出 Node.js 的安裝目錄,目錄的許可權屬性如圖:

這裡執行命令:

sudo chown vagrant:vagrant n node npm

記住還要清除 npm 緩衝:

npm cache clean

再次執行 sudo npm install –no-bin-links,Windows 環境下即使是在虛擬機器也需要帶上後面的參數。

好了,這個時候問題就解決。以上就是這篇文章的全部內容了,希望本文能對同樣遇到這個問題朋友們有所協助。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.