node-sass按照失败
node-sass
:rainbow: Node.js bindings to libsass
项目地址:https://gitcode.com/gh_mirrors/no/node-sass
免费下载资源
·
一、描述
从网上下载的一个Vue
模板项目,导入VsCode
,执行npm install
命令后,报错了,报错的信息是node-sass
安装失败,同时提示需要python
环境的错误信息,这是因为安装node-sass
失败了,而node-sass
依赖于Python
环境,node-sass
安装失败是因为默认是从国外线路下载,这些大家都是知道的,在网速不好的情况下,失败率很高。
1.核心错误日志如下:
Can't find Python executable "python", you can set the PYTHON env variable
2.控制台错误信息截图:
二、原因
- npm源速度慢。
- node-sass除了npm部分的代码,还会下载二进制文件binding.node,默认源是github,国内访问较慢,特殊时期甚至无法访问。
- node版本与node-sass版本不兼容。
- 缓存中binding.node版本不一致。
- 安装失败后重新安装。
- 提示没有安装python、build失败,假如拉取binding.node失败,node-sass会尝试在本地编译binding.node,过程就需要python。
三、解决方式
切换镜像源,切换为国内的淘宝镜像源
1.设置全局淘宝镜像源
npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/
2.安装node-sass
npm install node-sass
3. 启动vue项目
npm run dev
将镜像源设置为国内的淘宝之后,再随后执行npm run dev
启动开发环境服务即正常,完美解决问题。
4. 另外一种方案
1.先删除node_modules 文件夹。
2.npm install --global windows-build-tools
3. npm install node-sass --save
GitHub 加速计划 / no / node-sass
8.5 K
1.33 K
下载
:rainbow: Node.js bindings to libsass
最近提交(Master分支:1 个月前 )
6081731a
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3 to 4.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v3...v4)
---
updated-dependencies:
- dependency-name: actions/setup-node
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com> 8 个月前
62c0f46c
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)
---
updated-dependencies:
- dependency-name: actions/checkout
dependency-type: direct:production
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com> 8 个月前
更多推荐
已为社区贡献2条内容
所有评论(0)