Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack config from npm script

I have two scripts in package.json setup as follows,

    "scripts": {
"webpackDevServer": "babel-node ./node_modules/.bin/webpack-dev-server --config=webpack.config.dev.js --progress --colors",
    "webPack": "babel-node ./node_modules/.bin/webpack --config=webpack.config.dev.js"
}

When I execute it with > npm run webPack

I get this error,

basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^
SyntaxError: missing ) after argument list
    at Object.exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:543:28)
    at Module._extensions..js (module.js:580:10)
    at Object.require.extensions.(anonymous function) [as .js] (C:\Users\Xpert\WebstormProjects\Re\node_modules\babel-register\lib\node.js:152:7)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Function.Module.runMain (module.js:605:10)
    at C:\Users\Xpert\WebstormProjects\Re\node_modules\babel-cli\lib\_babel-node.js:155:24
    at Object.<anonymous> (C:\Users\Xpert\WebstormProjects\Re\node_modules\babel-cli\lib\_babel-node.js:156:7)

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "webPack"
npm ERR! node v7.5.0
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] webPack: `babel-node ./node_modules/.bin/webpack --config=webpack.config.dev.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] webPack script 'babel-node ./node_modules/.bin/webpack --config=webpack.config.dev.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the simprov package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     babel-node ./node_modules/.bin/webpack --config=webpack.config.dev.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs si
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls simprov
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Xpert\WebstormProjects\Re\npm-debug.log

The same happens when I do > npm run webpackDevServer

What am I doing wrong here?

-Thank you.

like image 423
Aki Avatar asked Nov 09 '22 01:11

Aki


1 Answers

babel-node at the beginning is unnecessary, just run "node_modules/.bin/webpack-dev-server"

like image 70
Mikołaj Żarnawski Avatar answered Dec 28 '22 10:12

Mikołaj Żarnawski