node-sass 安裝出錯常見解決方法

  1. 使用與 node-sass 版本兼容的 node

    到 package.json 中找到 node-sass 的版本號。使用 nvm 將 node 切換到與 node-sass 版本兼容的版本(sass/node-sass 有版本對照表)。

  2. 安裝指定版本的 python 並將其設置爲環境變量

    node-sass 依賴的可能是 python2,如果本機只安裝了 python3,則會報錯。

    先確保安裝了 python2,複製 python 解釋器的安裝路徑,比如D:\install\Python27\python.exe,運行npm config set python D:\install\Python27\python.exe,再運行npm install(可能需要先刪掉 node_modules 文件夾)。

參考:
2022:checking for Python executable "python2" in the PATH
爲什麼node-sass總是安裝失敗?

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章