webpack加载器安装node-sass失败的解决方法

webpack安装node-sass出现问题

我的问题反馈是这样的:

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/win32-x64-72_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.14.1/win32-x64-72_binding.node":

ESOCKETTIMEDOUT

Hint: If github.com is not accessible in your location
      try setting a proxy via HTTP_PROXY, e.g.

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080

原因是由于网络限制导致无法下载 .node 文件,解决方法如下:

使用淘宝镜像,使用镜像前请把node_modules文件夹下原有的node-sass有关的文件全删了

1.      npm install -g cnpm --registry = http://registry.npm.taobao.org

2.      cnpm install node-sass

上述第2步运行可能会碰到如下问题

cnpm : 无法加载文件 D:\Softwares\nodejs\node_global\cnpm.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Po
licies。
所在位置 行:1 字符: 1
+ cnpm install node-sass
+ ~~~~
    + CategoryInfo          : SecurityError: (:) [],PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

这是说是没有权限,需要用管理员身份进行运行并授权
解决方法:

打开本地的 Windows PowerShell,以管理员身份运行:

set-ExecutionPolicy RemoteSigned

再输入 Y 即可

猜你喜欢

转载自www.cnblogs.com/muzidaitou/p/12904874.html