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

前端 未结 30 2407
说谎
说谎 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 14:55

    * Docker related answer here *

    Answer for if you are seeing this problem, or something similar, and are using Docker.

    Cause: When copying over the current file structure to inside the Docker container, you may be copying over node modules from one OS system to another (e.g. a Mac to Linux container).

    Solution:

    Add a .dockerignore, and inside add:

    node_modules

    This will cause an npm install to install the bindings for the docker environment, rather than your local machine environment.

    0 讨论(0)
  • 2020-11-29 14:58

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

    Also works for VS 2017 and VS 2019 (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 & 2019, 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.

    0 讨论(0)
  • 2020-11-29 14:58

    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 installing and starting

    cd your_project
    rm -rf node_modules
    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
    
    0 讨论(0)
  • 2020-11-29 14:59

    Just refresh your npm cache and:

    npm cache clean --force  
    npm install
    

    It always works for me in the same case.

    UPD: Your problem may also be by reason of absence of a global sasslib.

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

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

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

    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.

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