madskristensen / WebPackTaskRunner

A Visual Studio extension
Other
40 stars 17 forks source link

Support for Webpack 2 #35

Open gregoryagu opened 7 years ago

gregoryagu commented 7 years ago

When I run webpack 2 on my project from a command line, it works fine. When I run the same from WebPack Task Runner it errors out.

There error that is thrown is Unexpected token '{'

This is the line that throws the error: const {AureliaPlugin} = require("aurelia-webpack-plugin");

Oddly, I can copy and paste the command from the TaskRunner into a command window and run it successfully.

This is the command it runs:

cmd /c SET NODE_ENV=development&& webpack -d --color

All the webpack commands fail from the Task runner for me.

ghost commented 7 years ago

Are you using the correct version of Node.js?

  1. Make sure you are running version 6+ (thats what I use and it works for me). To check this, open a cmd window and run: node -v

  2. Maybe even more important, make sure Visual Studio is using your global node.js, not its build in node.js version (which is old and does not support es6 syntax yet). To check this, open Visual Studio and go to: Tools -> Options ->Projects and Solutions -> External Web Tools. make sure that $(PATH) is listed ABOVE anything containing $(DevEnvDir). You can move $(PATH) up by clicking it and using the arrows at the top right of the window to move it up. This will make Visual Studio prefer the node.js thats in your PATH above its own version and things should work!

lawrentiy commented 7 years ago

The second variant above is fix for errors like "syntax error in webpack.js". My error was: bin\webpack.js:152 yargs.parse(process.argv.slice(2), (err, argv, output) => { ^ SyntaxError: Unexpected token >

Put it here for future finders.