我有问题构建一个应用程序,因为node-sass不断失败的错误。

binding /Users/warren/Sites/random-docs/my-cms/node_modules/node-sass/vendor/darwin-x64-11/binding.node出错 Node Sass无法找到当前环境的绑定:OS X 64位的Node 0.10.x

我试过跑步

npm rebuild node-sass

二进制很好;退出。

当运行node -v时,我得到v6.2.2

这与sass错误说的“Node 0.10.x”不同。我不明白为什么它会得到错误的版本。我也尝试删除node_modules文件夹并运行npm update或npm install,这两者都没有解决问题。什么好主意吗?


当前回答

我必须首先选择新的默认节点版本nvm use ***或nvm install ***,然后再次删除项目和npm I中的node_modules中的所有内容。

其他回答

没有一个安装/重建解决方案为我解决了这个问题(使用gulp)。

我是这样解决的:

1)从存储库下载丢失的绑定文件。

2)将文件重命名为binding.node。

3)如果不存在node_modules/node-sass/vendor/darwin-x64-11(错误信息中的路径)目录。

4)将绑定文件添加到“node_modules/node-sass/vendor/darwin-x64-11”目录下

对我来说,当我运行npm安装时,它审计了已安装的包,并显示“发现1个高严重漏洞”,并通过运行

npm audit fix

成功了。如果能帮助到别人就发布。

更新:共享错误日志:

ERROR in ./src/styles.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/styles.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Missing binding ..\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 10.x

This usually happens because your environment has changed since running `npm install`.
....

它确实要求我这么做

Run `npm rebuild node-sass` to download the binding for your current environment.

您可能有一个与当前版本不同的节点版本构建。尝试运行这些命令,应该可以解决问题。

npm cache clean --force &&  
rm -rf node_modules &&  
rm -rf package-lock.json &&  
npm i

Windows 10 This was a fun one for me... In order to resolve it I had to do all of the following.. 1.) Apparently node-sass isn't supported by some of the more recent versions of Node.js so I had to Uninstall Node-v 12.14.1, and delete the nodejs directory in C:/Program Files. 2.) Reinstall a earlier version of Node (for me 10.16.2 worked). NOTE: I had initially downloaded the x86 version so if your System is x64 download the x64 verison... 3.) From here I had to delete my entire project and re-clone it. After this things ran fine.

在我的例子中,我在package-lock中发现了node-sass版本。Json与package.json中的node-sass版本不同。这一步解决了我的问题。

删除文件夹node-modules 删除package-lock.json 安装python 2.7 将C:/Python27;C:/Python27/Scripts添加到环境变量->路径 在Powershell中,以管理员身份执行-> npm install -g node-gyp 在我的工作文件夹-> NPM安装

希望这也适用于你