node-sass 安裝失敗


筆者用 win 10 系統,在前端開發中遇到 node-sass 安裝各種問題,從網上找到解決方法。

用管理員打開 cmd/powershell 

1. 解決 win 缺少編譯環境

npm install -g node-gyp
// 用管理員權限打開 powershell 成功
npm install --global --production windows-build-tools

2. 安裝 node-sass

npm uninstall node-sass // 如果安裝過一次失敗,運行;否則不用
npm install node-sass --save-dev

 其他解決方法

SASS_BINARY_SITE=http://npm.taobao.org/mirrors/node-sass yarn

使用 yarn ,而在 yarn 前面加上 SASS_BINARY_SITE=http://npm.taobao.org/mirrors/node-sass ,是讓 yarn 去下載二進制文件

PS : 這個方法要在 git-base 控制台下,cmd下會提示 SASS_BINARY_SITE 不是內部或外部命令

下面這個方法類似

yarn config set sass-binary-site https://npm.taobao.org/mirrors/node-sass
npm config set sass-binary-site https://npm.taobao.org/mirrors/node-sass

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM