npm ERR! missing script build

2019-08-17 08:00发布

问题:

I'm using Windows 10 and powershell, trying to run a webpack app cloned from my github.

When I type npm run start I get:

npm ERR! missing script: build;

The build script is most definitely in my package.json:

"scripts": {
  "build": "webpack --mode development",
  "start": "npm run build; webpack-dev-server --open",
  "lint": "eslint src/*.js",
  "test": "karma start karma.conf.js"
},

When I'm on a mac, npm run start opens a local dev server just fine.

Any ideas why I am unable to run this on my pc? I am a rookie programmer. Answers written in plain English will be greatly appreciated.

The github repo with this project's config files:

https://github.com/GreanBeetle/api-project

I am happy to post the run log as well.

回答1:

In the root folder of your directory (or in whichever folder your webpack.config file is stored) run:

node_modules/.bin/webpack-dev-server

This gives command line access to the npm run start command

For further information:

https://www.npmjs.com/package/webpack-dev-server