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

前端 未结 30 2406
说谎
说谎 2020-11-29 14:23

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/nod

相关标签:
30条回答
  • 2020-11-29 15:07

    This happens when in your workstation you run an update of Node.js and you are using node-sass globally.

    So you should uninstall node-sass globally

    npm uninstall -g node-sass
    

    And then you have to install it globally, again

    npm install -g node-sass
    
    0 讨论(0)
  • 2020-11-29 15:07

    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.<anonymous> ([..]\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.<anonymous> ([..]\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).
    0 讨论(0)
  • 2020-11-29 15:07

    Open Visual Studio 2017
    Go to Tools -> Options…
    Go to Projects and Solutions -> Web Package Management
    Move $(PATH) to the top of that list and close that window.
    Restart Visual Studio.
    This worked in my case, because my node version is 11.x

    0 讨论(0)
  • 2020-11-29 15:08

    I'm a Windows 8 user, recently updated Node to v8.11.1 and npm to v6.0.0 and faced similar issue. Nothing worked - npm install -g node-sass@latest or deleting the node-sass directory from the project node_modules/ - none of 'em worked for me.

    The Laravel Mix was throwing an error to my browser console saying a missing node: win32-x64-57. I don't know whether it's because a slower internet connection or something, the node was missing during the update.

    Hence some of the answers directed me to look at the Node-Sass releases, and I found the solution.

    1. Step 1: Check your node-sass version using the command: npm view node-sass version (the {your version} in step 4)
    2. Step 2: Get to Node-Sass Releases
    3. Step 3: Get your release and find the missing node in the assets listed under every release, and download the file
    4. Step 4: Get to your PC's C:\Users\{User}\AppData\Roaming\npm-cache\node-sass\{your version}\ and put the downloaded .node file inside the version folder

    And you are done.

    In my case the node-sass version was 4.9.0 and the missing node was win32-x64-57_binding.node, so I downloaded the .node file from 4.9.0 release and followed step 4.

    0 讨论(0)
  • 2020-11-29 15:08

    I had this issue when upgrading from VS 2017 Professional to Enterprise

    1. Close VS
    2. Delete node_modules
    3. Open VS
    4. Right click package.json and select 'restore packages'
    0 讨论(0)
  • 2020-11-29 15:10

    I had the same issue. I couldn't find any proper working solution in here, so I found mine:

    Inspired by @Rob-Scott solution and other pointing that we could have 2 versions of Node.js installed, I went to C:\Program Files (x86)\nodejs and realized that I had a node.js version installed in addition to the VS default installation.

    My solution was quite simple:

    • Go to Tools > Options > Projects & solutions > Web package management > External web tools
    • Click on add an entry (most left of the top-right block of buttons)
    • Enter C:\Program Files (x86)\nodejs, validate by pressing enter
    • Bring it at the top of the list
    • Enjoy

    Probably Node.js is not set well in the PATH variable, but this is my working very quick solution, my 2 cents :)

    0 讨论(0)
提交回复
热议问题