npm ERR! missing script: dev npm ERR! A complete log of this run can be found in: npm ERR!

npm run dev
npm ERR! missing script: dev

npm ERR! A complete log of this run can be found in:
npm ERR!     E:\nodejs\node_cache\_logs\2018-12-12T15_06_08_674Z-debug.log

由于版本更新 npm run dev 和npm start 是老项目 运行方式
npm run XXX是执行配置在 package.json 中的脚本

"scripts": {
  "serve": "vue-cli-service serve",
  "build": "vue-cli-service build",
  "lint": "vue-cli-service lint"
},

npm run xxx 中的 xxx 可以理解为键值对的 key,实际上 run 的是在 package.json 里面 scripts 配置的 value;
比如,npm run serve 实际运行的是 vue-cli-service serve;
而放在 3.0 以前运行的则是 node build/dev-server.js 文件;
这时候我们再来看上边的问题是不是豁然了呢, scripts 中并没有配置 dev ,所以控制台报了 [ missing script: dev ] 的错误 ;

npm run xxx,并不是你想运行就运行的,只有在 package.json scripts 配置了,你才能 run 的,所以不是所有的项目都能 npm run dev/build。

要了解这些命令做了什么,就要去scripts中看具体执行的是什么代码。
这里就像是一些命令的快捷方式,免去每次都要输入很长的的命令(比如 serve 那行)
一般项目都会有 build, dev, unit 等,所以起名,最起码要从名字上基本能看出来是干什么的。

你可能感兴趣的:(npm ERR! missing script: dev npm ERR! A complete log of this run can be found in: npm ERR!)