madskristensen / WebPackTaskRunner

A Visual Studio extension
Other
39 stars 16 forks source link

Missing binding node-sass\vendor\win32-x64-47\binding.node #37

Closed JoshClose closed 7 years ago

JoshClose commented 7 years ago

Installed product versions

Description

When running the development config I get an error.

Module build failed: Error: Missing binding C:\<path to project>\node_modules\node-sass\vendor\win32-x64-47\binding.node
Node Sass could not find a binding for your current environment: Windows 64-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 --force` to build the binding for your current environment.

If I run it manually on the command line, everything works fine.

Steps to recreate

  1. Create a project that uses webpack.
  2. yarn add bulma
  3. yarn add --dev style-loader css-loader node-sass sass-loader webpack
  4. Create an index.js file that contains import "../node_modules/bulma/bulma.sass"
  5. Create a webpack.config.js file that includes the sass-loader
const path = require("path");

module.exports = {
    entry: "./wwwroot/js/index.js",
    output: {
        path: path.resolve(__dirname, "wwwroot/js"),
        filename: "bundle.js"
    },
    module: {
        rules: [{
            test: /\.s[ca]ss$/,
            use: [{
                loader: "style-loader" // creates style nodes from JS strings
            }, {
                loader: "css-loader" // translates CSS into CommonJS
            }, {
                loader: "sass-loader" // compiles Sass to CSS
            }]
        }]
    },
    devtool: "source-map"
};
  1. Run from the command line to ensure it works properly.
  2. Run from Task Runner

Current behavior

It's giving me an error (stated above) that doesn't occur when running directly from the command line.

Expected behavior

Should work exactly like the command line execution does.

scottaddie commented 7 years ago

In VS 2017, please try again after making the following change:

  1. Tools > Options > Projects and Solutions > Web Package Management > External Web Tools
  2. Move the $(PATH) entry to the 2nd position in the list by using the up arrow button.
JoshClose commented 7 years ago

That works. Thanks! It's interesting to see what's floating around in the $(VSINSTALLDIR)\Web\External location.

bdelaney commented 6 years ago

Recently ran into this after opening a project had been using Grunt and older version of Node. In new system had latest version of Node installed and I reran NPM install after updating all Grunt packages. No matter what I did, had Node-SASS error in my Task Runner window in VS. But at command line Grunt appeared to be running fine. Following Scott's advice to move the $(path) up the list worked for me!

amirdelfan commented 6 years ago

The solution of scottaddie helped me too. npm rebuild node-sass dit not help me. Anyways because npm install should already get the right npm packages for you. If you are running VS2013 because the external web tools setting is not availible I think the only solution is to copy the file (binding.node) manually. Still until now I don't understand how this suddenly became an issue. Maybe an update of npm? Maybe someone can explain this?

richardhuf84 commented 6 years ago

I was able to fix this issue by getting the relevant node binding file from here: https://github.com/sass/node-sass-binaries

I had to create a folder in node_modules/node-sass/vendor called 'win32-x64-47' and rename the downloaded binary to 'binding.node'.

After recompiling it fixed the issue.