这个错误看到网上很多帖子都说什么手动下载,什么版本问题,很不实用,我们需要搭建仓库就是为了后面其他同事下载的时候方便,所以就写了这篇经验贴。

在我们本地npm install的时候会有下面两个参数可以配置:

registry=https://registry.npmjs.org/

sass_binary_site=https://npm.taobao.org/mirrors/node-sass/

这两个配置是给大家普及一下,这两个参数,一个是npm的源地址,一个是sass二进制文件源地址。

你在搭建Nexus npm私服时遇到的问题与node-sass的二进制包下载失败有关。这通常是因为node-sass包中包含有本地二进制文件(_binding.node),而在某些情况下,下载过程可能会失败。

解决办法:要在nexus私服中创建另一个类型为 raw(proxy) 的repository,用这个仓库代理淘宝源中的node-sass,也就是相当于我们的sass_binary_site参数

raw就是我们用来代理二进制的库,配置如下:

存储空间这这块,我选择了和之前的三个仓库(npm(group),npm(hosted),npm(proxy))放在同一个存储空间里。

接下来再项目中操作:

在项目根目录下执行以下命令:

npm cache clean --force

清缓存,不然会影响后续操作

第二步:

执行设置代理命令:

npm config set sass_binary_site http://localhost:8888/repository/node-sass

这里的 http://localhost:8888   根据你的nexus仓库地址进行替换。

第三步:

检测代理是否设置成功:

npm config get sass_binary_site
第四步:

重新执行 npm install命令,不再报错,然后run,顺利启动项目。

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 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐