node.js Node Sass 找不到适合您当前环境的绑定

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37986800/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 20:19:28  来源:igfitidea点击:

Node Sass couldn't find a binding for your current environment

node.jsnpm

提问by wazzaday

I am having issues building an app because node-sass keeps failing with the error.

我在构建应用程序时遇到问题,因为 node-sass 一直因错误而失败。

ERROR in Missing binding /Users/warren/Sites/random-docs/my-cms/node_modules/node-sass/vendor/darwin-x64-11/binding.node
Node Sass could not find a binding for your current environment: OS X 64-bit with Node 0.10.x

缺少绑定错误 /Users/warren/Sites/random-docs/my-cms/node_modules/node-sass/vendor/darwin-x64-11/binding.node
Node Sass 找不到适合您当前环境的绑定:OS X 64 位节点 0.10.x

I have tried running

我试过跑步

npm rebuild node-sass

which says

其中说

Binary is fine; exiting.

二进制很好;退出。

When running node -vI get v6.2.2

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

Which is different to what the sass error says "Node 0.10.x". I can't figure out why it is getting the wrong version. I have also tried removing the node_modules folder and running npm update or npm install, both of which did not resolve the issue. Any ideas?

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

回答by Bipon Biswas

I had the same problem

我有同样的问题

There is an error in your gulpfile:
Error: Missing binding E:\allapp\badshaindiancuisine\node_module\node-sass\vendor\win32-x64-46\binding.node
Node Sass could not find a binding for your current environment:Windows 64-bit with Node.js 4.x

Found bindings for the following environment:
? ? - OS X 64-bit with Node.js 4.x

您的 gulpfile 中存在错误:
错误:缺少绑定 E:\allapp\badshaindiancuisine\node_module\node-sass\vendor\win32-x64-46\binding.node
Node Sass 找不到适合您当前环境的绑定:Windows 64 -位与 Node.js 4.x

找到以下环境的绑定:
? ? - 带有 Node.js 4.x 的 OS X 64 位

How to solve my problem

如何解决我的问题

By going into project folder and then execute:

通过进入项目文件夹然后执行:

npm rebuild node-sass

回答by Rob Scott

Note I'm using VS 2015, 64-bit Windows 7.

注意我使用的是 VS 2015,64 位 Windows 7。

Also works for VS 2017 and VS 2019 (from replies to this post)

也适用于 VS 2017 和 VS 2019(来自对这篇文章的回复)

Task Runner Explorer can't load tasks

Task Runner Explorer 无法加载任务

For VS 2015

对于 VS 2015

  • Go to: Tools > Options > Projects and Solutions > External Web Tools
  • 转到:工具 > 选项 > 项目和解决方案 > 外部 Web 工具

For VS 2017(.3)

对于 VS 2017(.3)

  • Tools > Options > Projects and Solutions > Web Package Management > External Web Tools (per @nothrow)
  • 工具 > 选项 > 项目和解决方案 > Web 包管理 > 外部 Web 工具(根据 @nothrow)

In VS 2017 & 2019, you also need to put $(PATH) above $(VSINSTALLERDIR)\Web\External

在 VS 2017 和 2019 中,您还需要将 $(PATH) 放在 $(VSINSTALLERDIR)\Web\External 之上



  • Reorder so that $(PATH) is above $(DevEnvDir)\Extensions\Microsoft\Web Tools\External
  • 重新排序,使 $(PATH) 高于 $(DevEnvDir)\Extensions\Microsoft\Web Tools\External

enter image description here

在此处输入图片说明



Deleting node_modulesand running npm installand then npm rebuild node-sassdid nothing.

删除node_modules并运行npm install然后npm rebuild node-sass什么也没做

回答by Beofett

I had the same problem in a Windows environment, receiving the following error:

我在 Windows 环境中遇到了同样的问题,收到以下错误:

Error: Missing binding C:\Development{ProjectName}\node_modules\node-sass\vendor\win32-ia32-47\binding.node
Node Sass could not find a binding for your current environment: Windows 32-bit with Node.js 5.x
Found bindings for the following environments:
?? - Windows 64-bit with Node.js 6.x

错误:缺少绑定 C:\Development{ProjectName}\node_modules\node-sass\vendor\win32-ia32-47\binding.node
Node Sass 找不到适合您当前环境的绑定:Windows 32-bit with Node.js 5 .x
找到以下环境的绑定:
?? - 带有 Node.js 6.x 的 Windows 64 位

None of the npmcommands listed in the other answers here (npm install, npm rebuild node-sass, etc.) worked.

在没有npm在这里的其他答案(列出的命令npm installnpm rebuild node-sass等)的工作。

Instead, I had to download the missing binding and place it in the appropriate destination folder.

相反,我必须下载缺少的绑定并将其放在适当的目标文件夹中。

The bindings can be found on git. Match the file with the folder name identified after /node_modules/node-sass/vendor/in your error message ('darwin-x64-11' in your case, so you'd want the darwin-x64-11_binding.nodefile).

绑定可以在 git上找到。将文件与/node_modules/node-sass/vendor/错误消息中标识的文件夹名称匹配(在您的情况下为“darwin-x64-11”,因此您需要该darwin-x64-11_binding.node文件)。

Create the missing folder in your project (/node_modules/node-sass/vendor/darwin-x64-11), copy the .nodefile to the new directory, and rename it to binding.node.

在您的项目 ( /node_modules/node-sass/vendor/darwin-x64-11) 中创建丢失的文件夹,将.node文件复制到新目录,并将其重命名为binding.node.

Node-sass release URL: https://github.com/sass/node-sass/releases

Node-sass 发布网址:https: //github.com/sass/node-sass/releases

回答by Codiee

Worked for me:

对我来说有效:

Just delete the node-sass folder and run npm install.

只需删除 node-sass 文件夹并运行npm install.

回答by Legends

Just execute:npm rebuild node-sass --force

只需执行:npm rebuild node-sass --force



If the above for some reason didn't work out for you, try this:

如果以上由于某种原因对您不起作用,请尝试以下操作:

  1. Delete node-sassfolder under node_modules
  2. npm install
  1. 删除node-sass文件夹下node_modules
  2. npm install


In my case it also couldn't find Python.

就我而言,它也找不到Python.

Following procedure solved the issue (Windows):

以下过程解决了该问题(Windows):

npm rebuild node-sass --force
-- cannot find python.exe, if you have Python installed, add it to your path:
set PYTHON=C:\Python27\Python.exe
-- else: download python "Windows x86-64-MSI" installer from https://www.python.org/downloads/release/python-2714/
-- install python
-- at installation start check: add env variable to path
-- after successfull installation:
npm rebuild node-sass --force
-- finished successfully

回答by Sherwood Callaway

npm rebuild node-sass --force

npm rebuild node-sass --force

Or, if you are using node-sass within a container:

或者,如果您在容器中使用 node-sass:

docker exec <container-id> npm rebuild node-sass --force

docker exec <container-id> npm rebuild node-sass --force

This error occurs when node-sass does not have the correct binding for the current operating system.

当 node-sass 没有当前操作系统的正确绑定时会发生此错误。

If you use Docker, this error usually happens when you add node_modulesdirectly to the container filesystem in your Dockerfile (or mount them using a Docker volume).

如果您使用 Docker,当您node_modules直接添加到 Dockerfile 中的容器文件系统(或使用 Docker 卷挂载它们)时,通常会发生此错误。

The container architecture is probably different than your current operating system. For example, I installed node-sass on macOS but my container runs Ubuntu.

容器架构可能与您当前的操作系统不同。例如,我在 macOS 上安装了 node-sass,但我的容器运行的是 Ubuntu。

If you force node-sass to rebuild from within the container, node-sass will download the correct bindings for the container operating system.

如果您强制 node-sass 从容器内重建,node-sass 将为容器操作系统下载正确的绑定。

See my repro caseto learn more.

请参阅我的重现案例以了解更多信息。

回答by Rocío García Luque

I had a similar problem and the reason was that there were two versions of Node installed in my machine: one "global" and another one at the project level. Sass will build correctly only if the Gulp build is running under Node.js 4.x version, so make sure you upgrade the version of Node you are using.

我遇到了类似的问题,原因是我的机器上安装了两个版本的 Node:一个是“全局”版本,另一个是项目级别的。仅当 Gulp 构建在 Node.js 4.x 版本下运行时,Sass 才能正确构建,因此请确保升级您正在使用的 Node 版本。

PS: If you completely remove the node_modulesfolder in your project and re-build from scratch, npm will download the correct dependencies for your current system & node version.

PS:如果您完全删除项目中的node_modules文件夹并从头开始重新构建,npm 将为您当前的系统和节点版本下载正确的依赖项。

回答by core114

in some cases you need to uninstall and install node-sass library. Try:

在某些情况下,您需要卸载并安装 node-sass 库。尝试:

npm uninstall --save node-sass

and

npm install --save node-sass

look at this its work for me, Stack link here

看看这对我有用堆栈链接在这里

回答by user3890355

Try to add suffix --force

尝试添加后缀--force

npm rebuild node-sass --force

回答by Alex Pandrea

For my particular case none of the above answers worked. So what it worked:

对于我的特殊情况,上述答案均无效。那么它的工作原理是:

rm -rf node_modules 
rm -rf /tmp/* 
rm -rf /root/.npm/node-sass 
npm uninstall --save node-sass 
npm cache clean --force 

npm cache verifyto check that nothing is left in the cache

npm cache verify检查缓存中没有留下任何东西

npm install

Altough I haven't tried to reproduce the sequence it was a combination of the above that worked. In addition you may also try:

尽管我没有尝试重现序列,但它是上述方法的组合。此外,您还可以尝试:

npm install --save node-sassor npm install node-sass -g

npm install --save node-sass或者 npm install node-sass -g

npm rebuild node-sass
npm install bindings