npm run命令需和项目根目录下的package.json文件配合使用;
npm run执行package.json文件的“scripts”属性中定义的命令,如下例:
{
"name": "my-project",
"version": "1.0.0",
"description": "A Vue.js project",
"author": "zhouguoqing <zhouguoqing@clinbrain.com>",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"unit": "jest --config test/unit/jest.conf.js --coverage",
"e2e": "node test/e2e/runner.js",
"test": "npm run unit && npm run e2e",
"lint": "eslint --ext .js,.vue src test/unit test/e2e/specs",
"build": "node build/build.js"
}
}
在项目根目录下打开终端(cmd或power shell),执行npm run build,将执行node命令:node build/build.js
执行npm run start,将执行npm run dev,进而执行webpack-dev-server...命令,以上。