目录

1. Downloading https://chromedriver.storage.googleapis.com/2.41/chromedriver_window32...报错

2. node-sass 安装失败: Failed at the node-sass@4.12.0 postinstall script.

3... 待续


1. Downloading https://chromedriver.storage.googleapis.com/2.41/chromedriver_window32...报错

在使用 vue init 初始化项目之后,使用 npm i 装包;或者是查看别人的项目时安装依赖包的时候,有时候会在安装chromedeiver的时候出现卡住不能继续执行或者报错……

这是由于在某些版本下,Chromedriver的zip文件URL的响应是302跳转,但是在install.js里面使用的是node.js内置的http对象的get方法,无法处理302跳转的情况。或者另一种情况:googleleapis.com被墙了。

解决方法:

在 npm install 执行之前,手动安装Chromedriver,命令如下:

npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver

2. node-sass 安装失败: Failed at the node-sass@4.12.0 postinstall script.

快速解决方法: 使用cnpm安装,(npm有时候不稳定)

(1)首次报错信息主要内容如下:

Failed at the node-sass@4.12.0 postinstall script.

'Error: not found: python2\n    at getNotFoundError... (其他省略) '

这是由于找不到Python2,原因可能为:没有安装Python,或者需要配置环境变量(Can't find Python executable "python", you can set the PYTHON env variable)

解决方法:

安装 python-2.7.16.amd64,安装的时候记得勾选 “Add Python to Path" 选项(默认不勾选)

(2)安装完成后,依然报错:

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

read ECONNRESET

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-sass被墙掉了,所以要使用淘宝镜像进行安装。

npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm i

PS: 看到有教程推荐直接到GitHub上下载一个 win32-x64-64_binding.node 然后配置路径使之可以访问,也有人说最好不要这么做,可能会导致版本不同步导致命令报错无法执行,目前没有遇到这样的情况,在此记录一下。

3... 待续

Logo

前往低代码交流专区

更多推荐