直接npm install
时遇到sass软件报错
npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
npm ERR! gyp ERR! stack at PythonFinder.failNoPython (D:\code\cesium-demo\node_modules\node-gyp\lib\configure.js:484:19)
npm ERR! gyp ERR! stack at PythonFinder.<anonymous> (D:\code\cesium-demo\node_modules\node-gyp\lib\configure.js:509:16)
npm ERR! gyp ERR! stack at callback (D:\code\cesium-demo\node_modules\graceful-fs\polyfills.js:306:20)
npm ERR! gyp ERR! stack at FSReqCallback.oncomplete (node:fs:202:21)
npm ERR! gyp ERR! System Windows_NT 10.0.19045
npm ERR! gyp ERR! command "C:\\nvm\\nodejs\\node.exe" "D:\\code\\cesium-demo\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
直接使用淘宝镜像源
设置变量 sass_binary_site,指向淘宝镜像地址。示例:
sh
npm i node-sass --sass_binary_site=https://registry.npmmirror.com/node-sass/
// 也可以设置系统环境变量的方式。示例
// linux、mac 下
SASS_BINARY_SITE=https://registry.npmmirror.com/node-sass/ npm install node-sass
// window 下
set SASS_BINARY_SITE=https://registry.npmmirror.com/node-sass/ && npm install node-sass
或者直接全局设置
sh
npm config set sass_binary_site npm i node-sass --sass_binary_site=https://registry.npmmirror.com/node-sass/
npm install node-sass
同时需要注意node-sass 版本和 node 版本对应关系
可以在此处查看