Node.js升级为8.x报错:Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 8.x

已解决 node.js
0

把 node 从 6.x 升级到 8.x 后,旧项目编译 scss 文件时报错:

ERROR in ./src/app/note/account/user.component.scss
Module build failed: Error: Missing binding D:\web\my-project\node_modules\node-sass\vendor\win32-x64-57\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 8.x
Found bindings for the following environments:
  - Windows 64-bit with Node.js 6.x
This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass --force` to build the binding for your current environment.
    at module.exports (D:\web\my-project\node_modules\node-sass\lib\binding.js:15:13)
    at Object.<anonymous> (D:\web\my-project\node_modules\node-sass\lib\index.js:14:35)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (D:\web\my-project\node_modules\sass-loader\lib\loader.js:3:14)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)

原来项目绑定的是 Windows 64-bit with Node.js 6.x。

如果觉得这对你有用,请随意赞赏,给与作者支持
回答 (1)
1 个回答

0

已采纳

在错误提示里有给出了方案,重新构建 node-sass,命令如下:

npm rebuild node-sass --force

如果执行完成后不报错,就可以了。

也有可能会报 gyp Error 错误:

gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
....
gyp ERR! node -v v8.11.1 
gyp ERR! node-gyp -v v3.6.2

就需要先卸载 node-sass,然后重新安装。

npm uninstall node-sass
npm install node-sass