madskristensen / NpmTaskRunner

Visual Studio extension
Other
88 stars 32 forks source link

Webpack 2 build terminates with errors #47

Closed embee8 closed 7 years ago

embee8 commented 7 years ago

Installed product versions

Description

I upgraded to Webpack 2 today and now the Webpack build throws an error when started through the NPM Task Runner.

Steps to recreate

Run either of the two defined scripts below through the NPM Task Runner for the following project structure / package versions.

{
  "dependencies": {
    "babel-plugin-react-css-modules": "^2.2.0",
    "react": "^15.4.2",
    "react-dom": "^15.4.2",
    "jquery": "3.1.1",
    "es6-promise": "^4.0.5"
  },
  "devDependencies": {
    "babel-core": "^6.22.1",
    "babel-loader": "^6.2.10",
    "babel-preset-es2015": "^6.22.0",
    "babel-preset-react": "^6.22.0",
    "css-loader": "0.26.1",
    "babel-plugin-transform-react-jsx": "^6.22.0",
    "extract-text-webpack-plugin": "2.0.0-rc.3",
    "style-loader": "0.13.1",
    "expose-loader": "^0.7.1",
    "webpack": "^2.2.1"
  },
  "scripts": {
    "webpack-watch": "webpack -w",
    "webpack-once": "webpack"
  }
}

Current behavior

This is the output I currently get:

webpack Process terminated with code 1. C:\Users\abc\Documents\Visual Studio 2015\Projects\abc\abc\node_modules\webpack\bin\webpack.js:186 outputOptions.children = options.map(o => o.stats); ^ SyntaxError: Unexpected token > at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:906:3

If I start Webpack in a normal console window outside of the task runner it works fine. It looks like VS or this extension is using a different npm version?

Expected behavior

I am not sure whether this extension brings in its own external version of NPM or not. I would appreciate your insights.

scottaddie commented 7 years ago

VS 2015 ships with its own versions of Node and npm. Consequently, you'll want to tell VS to use the versions set on your system/user PATH environment variable. To do this, go to Tools --> Options --> Projects and Solutions --> External Web Tools, and move the $(PATH) entry to the 2nd position in the list. You should have something that looks like this: external_web_tools

embee8 commented 7 years ago

Beautiful! I changed the order and the scripts now run again. Thank you for your swift reply, @scottaddie!

scbdhol commented 7 years ago

Great answer! Solved this issue for me too.