30

In my package.json I'm trying to use webpack in a script but it keeps failing.

  "scripts": {
    "start": "node server.js",
    "test": "mocha 'src/**/test*.coffee' --watch --compilers coffee:coffee-script/register",
    "build": "webpack --config webpack.dist.config.js"
  },

the scripts start and test works as expected but when running npm build in terminal I'm getting nothing:

➜  client git:(master) ✗ npm build
➜  client git:(master) ✗ 

When running the command manually, things happen:

➜  client git:(master) ✗ webpack --config webpack.dist.config.js
Hash: 9274a04acd39605afc25
Version: webpack 1.9.10
Time: 5206ms
    Asset     Size  Chunks             Chunk Names
bundle.js  5.23 MB       0  [emitted]  main
   [0] multi main 28 bytes {0} [built]
 [349] ../config.js 181 bytes {0} [built]
    + 413 hidden modules
➜  client git:(master) ✗ 

Have I miss understod how npm scripts are suppose to work?

Cotten
  • 8,787
  • 17
  • 61
  • 98

2 Answers2

48

Use: npm run build

Reason: npm start & npm test are shortcuts for npm run start & npm run test, for any other npm tasks, you have to specify "run"

bugwheels94
  • 30,681
  • 3
  • 39
  • 60
topheman
  • 7,422
  • 4
  • 24
  • 33
9

Run npm run build.

start and test are built in scripts for npm. build however is a custom script and thus needs to be invoked with npm run build.

You can find out more about npm's scripts here

Mario Tacke
  • 5,378
  • 3
  • 30
  • 49