Node Sass could not find a binding for your current environment

匿名 (未验证) 提交于 2019-12-03 01:25:01

问题:

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

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

I have tried running

npm rebuild node-sass 

which says

Binary is fine; exiting.

When running node -v I get v6.2.2

Which is different to what the sass error says "Node 0.10.x". I cant 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?

回答1:

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:

How to solve my problem

At first going into project folder. Then execute:

npm rebuild node-sass 


回答2:

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

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

Task Runner Explorer can't load tasks

For VS 2015

  • Go to: Tools > Options > Projects and Solutions > External Web Tools

For VS 2017(.3)

  • Tools > Options > Projects and Solutions > Web Package Management > External Web Tools (per @nothrow)

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


  • Reorder so that $(PATH) is above $(DevEnvDir)\Extensions\Microsoft\Web Tools\External


Deleting node_modules and running npm install and then npm rebuild node-sass did nothing.



回答3:

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

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:

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

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.node file).

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

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



回答4:

Worked for me:

Just delete the node-sass folder and run npm install



回答5:

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.

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



回答6:

Try to add suffix --force

npm rebuild node-sass --force 


回答7:

I had the same problem with Node v7.4.0 Current (Latest Features).

Did some reading here and downgraded Node to v6.9.4 LTS and after running npm rebuild node-sass it downloaded the binary and everything started working.

Downloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-48_binding.node
Download complete .] - :
Binary saved to D:\xxx\xxx-xxx\node_modules\node-sass\vendor\win32-x64-48\binding.node
Caching binary to C:\Users\user\AppData\Roaming\npm-cache\node-sass\3.13.1\win32-x64-48_binding.node`



回答8:

I had the same problem

    throw new Error(errors.missingBinary());     ^  Error: Missing binding /path/to/project/node_modules/node-sass/vendor/linux-x64-47/binding.node Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 5.x  Found bindings for the following environments:   - Linux 64-bit with Node 0.10.x   - Linux 64-bit with Node.js 5.x 

That was because I did npm install using a different nodejs version, try deleting node_modules folder and start

npm install npm start or gulp or whatever 

If you are using nvm do

nvm use stable // or your favorite version // remove node_module directory npm install npm start or gulp or whatever 


回答9:

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

npm uninstall --save node-sass 

and

npm install --save node-sass 

look at this its work for me, Stack



回答10:

This usually happens because the environment has changed since running npm install. Running npm rebuild node-sass builds the binding for the current environment.



回答11:

A similar error I encountered with Visual Studio 2015 Community Edition while having created an AspNetCore app was:

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 This usually happens because your environment has changed since running `npm install`. Run `npm rebuild node-sass` to build the binding for your current environment.     at module.exports ([..]\node_modules\node-sass\lib\binding.js:15:13)     at Object. ([..]\node_modules\node-sass\lib\index.js:14:35)     at Module._compile (module.js:397:26)     at Object.Module._extensions..js (module.js:404:10)     at Module.load (module.js:343:32)     at Function.Module._load (module.js:300:12)     at Module.require (module.js:353:17)     at require (internal/module.js:12:17)     at Object. ([..]\node_modules\gulp-sass\index.js:187:21)     at Module._compile (module.js:397:26) 

You can see the from the error above that the cause was from a version mismatch on the bindings for nodejs.

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

The solution I found was to

  • Install the nodejs windows version,
  • Add path for node js (C:\Program Files\nodejs) in External Web Tools (see Rob Scott's answer),
  • Move nodejs path above $(PATH).


回答12:

For Visual Studio 2015/2017, Right Click on your package.json and Click on Restore Packages.

This will make sure that the npm from the Visual Studio Tools External Tools is run and the binding will be rebuild based on that.



回答13:

This worked for me Deleting node_modules and then restoring packages from IDE and then npm rebuild node-sass



回答14:

I just run npm rebuild instead of npm rebuild node-sass and issue gone.. I don't know what is the magic behind though.



回答15:

node-sass runs an install script to download the required binary. If there are no environment variables, .npmrc variables or process arguments set then the binary is determined by using the current process platform, architecture and Node ABI version. Therefore, if you run node install in one application and then try to run node-sass in an application with a different platform/architecture/ABI, the binary won't have been downloaded. The solution is to manually download the binary or to fix the binary version using an environment variable (SASS_BINARY_NAME) or a .npmrc variable (sass_binary_name)

You can see the logic for this in the getBinaryPath function in node-sass\lib\extensions.js



回答16:

 Check your system. Does your system has 2 different notejs installation? If you install node from nodejs site default installation directory C:\Program Files\nodejs  I have the node version 6.xx installed here  Check your VS External web tools directory C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Web\External I have the node version 5.xx installed there. One  work around is Make backup of C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Web\External directory. Copy C:\Program Files\nodejs  directory content and paste into  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Web\External  Directory. Delete node_modules directory from your solution.  Re run the project. If you get error message re run the project second time.   If that does not work - Delete node_modules directory from your solution. NOTE: $ is the command prompt $  npm install  … $ npm run build:dev Rerun the project. 


回答17:

Please also remember to rename the xxx.node file ( in my case win32-x64-51) to binding.node and paste in the xxx folder ( in my case win32-x64-51),



回答18:

For people that switched to nvm from system node, if you haven't removed the ~/.npm and ~/.node-gyp folder this problem can arise since perhaps the node version within ~/.node-gyp could be different.

In any case those folders should be removed.



回答19:

Answer by @core114 suggesting Uninstalling & installing sass package again works fine for manual process but for automated deployment/CI/CD you need more generic approach. What worked for me is for Continuos deployment of different environment is :

  1. removing old node_modules using rimraf before deployment

    rimraf node_modules

  2. Updating sass package in npm package.json & committing to source control.

For next deployment it will automatically refresh sass for all environment.



回答20:

The problem for me was that the Task Runner Explorer was targeting the solution of my project. When I changed to the project itself using the drop-down list, next to the Task Runner Explorer refresh button, it showed the relevant tasks.



回答21:

Windows:

npm rebuild node-sass --force should do the trick.

In my case it also couldn't find Python.

Following procedure solved the issue:

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 -- downloading python Windows x86-64 MSI installer : 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 npm run build --works again 


回答22:

For Mac:

  1. -CMD+SHIFT+G
  2. -/usr/local/lib/node-sass
  3. -right click and renamed: should still the same node-sass
  4. -then run: npm install node-sass -g

that fixed.



回答23:

Remove

"dependencies": { "node-sass": "^3.13.1" // version may be different in your case },

from your package.json



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!