在vue-cli中,我想npm run dev
,但是得到了以下错误:
$ npm run dev
> vuejs-playlist@1.0.0 dev /Users/den/Desktop/Test/vue/vuejs-playlist
> cross-env NODE_ENV=development webpack-dev-server --open --hot
sh: cross-env: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! vuejs-playlist@1.0.0 dev: `cross-env NODE_ENV=development webpack-dev-server --open --hot`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the vuejs-playlist@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/den/.npm/_logs/2018-02-02T11_54_11_067Z-debug.log
答案 0 :(得分:2)
对@ vue / cli尝试以下操作
npm run serve
答案 1 :(得分:1)
在追溯中:
本地package.json存在,但缺少node_modules,你的意思是安装吗?
您应该在项目根目录中安装依赖项:
npm install
或使用其徽标npm i
答案 2 :(得分:0)
如前所述,您的构建因首先需要而失败:
npm install
完成后,检查您的package.json文件。
其中将包含npm run
的默认选项,后跟您的构建脚本选项。
示例:
{
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
}
}
您的npm run serve
与vue-cli-service serve
的结果
参考:Vue Docs