在Vue-CLI中运行dev,失败。

时间:2018-02-02 12:03:53

标签: npm vue.js vue-cli

在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

3 个答案:

答案 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 servevue-cli-service serve的结果

参考:Vue Docs