快捷搜索: 王者荣耀 脱发

node版本升级后vue项目启动错误(node-sass sass-loader)

在升级完node版本后启动项目发现报错,这是由于版本兼容导致的,关键报错如下:

Downloading binary from https://npm.taobao.org/mirrors/node-sass/v4.12.0/win32-x64-93_binding.node
Cannot download "https://npm.taobao.org/mirrors/node-sass/v4.12.0/win32-x64-93_binding.node": 

HTTP error 404 Not Found

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
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.12.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.12.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersAdministratorAppDataRoaming
pm-cache\_logs2022-06-15T13_59_40_556Z-debug.log

以前的版本信息:

以前我的node版本为:v14.5.1

又去看了下node与sass-node的版本对应表

可以看到前面是没问题的,但是我现在node版本升级为了:v16.15.1

所以node-sass就必须要6.0+的版本才行

还得去看node-sass与sass-loader的对应版本,把sass-loader也换为对应的版本

我这里v16.15.1需要的版本:

npm install node-sass@6.0.1 sass-loader@10.2.0

版本更换完成,问题解决。

经验分享 程序员 微信小程序 职场和发展