简体   繁体   English

使用vue-cli的Vuejs:运行“npm run dev”时出错

[英]Vuejs with vue-cli: Error when running “npm run dev”

My environment: 我的环境:

  • Centos7 on VirtualBox (true OS : Windows 7) VirtualBox上的Centos7(真正的操作系统:Windows 7)
  • Node version: 6.10.3 节点版本:6.10.3
  • Npm version : 3.10.10 Npm版本:3.10.10
  • I'm behind a corporate proxy 我是公司代理的幕后黑手

I installed vue-cli, like this: 我安装了vue-cli,像这样:

sudo npm install -g vue-cli

Then I initialized a new project "vuetest", like this: 然后我初始化了一个新项目“vuetest”,如下所示:

vue init webpack-simple vuetest

Then I ran this command in the "vuetest" folder: 然后我在“vuetest”文件夹中运行此命令:

sudo npm install

But now, I get an error when running "npm run dev". 但现在,运行“npm run dev”时出错。 The error: 错误:

> vuetest@1.0.0 dev /var/www/html/vuetest
> cross-env NODE_ENV=development webpack-dev-server --open --hot

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: spawn webpack-dev-server ENOENT
    at exports._errnoException (util.js:1018:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
    at Module.runMain (module.js:606:11)
    at run (bootstrap_node.js:390:7)
    at startup (bootstrap_node.js:150:9)
    at bootstrap_node.js:505:3

npm ERR! Linux 3.10.0-514.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! vuetest@1.0.0 dev: `cross-env NODE_ENV=development webpack-dev-server --open --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vuetest@1.0.0 dev script 'cross-env NODE_ENV=development webpack-dev-server --open --hot'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the vuetest package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=development webpack-dev-server --open --hot
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs vuetest
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls vuetest
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/html/vuetest/npm-debug.log

EDIT : here's the contents of the "npm-debug.log" file: 编辑:这是“npm-debug.log”文件的内容:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'dev' ]
2 info using npm@3.10.10
3 info using node@v6.10.3
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle vuetest@1.0.0~predev: vuetest@1.0.0
6 silly lifecycle vuetest@1.0.0~predev: no script for predev, continuing
7 info lifecycle vuetest@1.0.0~dev: vuetest@1.0.0
8 verbose lifecycle vuetest@1.0.0~dev: unsafe-perm in lifecycle true
9 verbose lifecycle vuetest@1.0.0~dev: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/var/www/html/vuetest/node_modules/.bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/bdupre/.local/bin:/home/bdupre/bin
10 verbose lifecycle vuetest@1.0.0~dev: CWD: /var/www/html/vuetest
11 silly lifecycle vuetest@1.0.0~dev: Args: [ '-c',
11 silly lifecycle   'cross-env NODE_ENV=development webpack-dev-server --open --hot' ]
12 silly lifecycle vuetest@1.0.0~dev: Returned: code: 1  signal: null
13 info lifecycle vuetest@1.0.0~dev: Failed to exec dev script
14 verbose stack Error: vuetest@1.0.0 dev: `cross-env NODE_ENV=development webpack-dev-server --open --hot`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:191:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:191:7)
14 verbose stack     at maybeClose (internal/child_process.js:886:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid vuetest@1.0.0
16 verbose cwd /var/www/html/vuetest
17 error Linux 3.10.0-514.el7.x86_64
18 error argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
19 error node v6.10.3
20 error npm  v3.10.10
21 error code ELIFECYCLE
22 error vuetest@1.0.0 dev: `cross-env NODE_ENV=development webpack-dev-server --open --hot`
22 error Exit status 1
23 error Failed at the vuetest@1.0.0 dev script 'cross-env NODE_ENV=development webpack-dev-server --open --hot'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the vuetest package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     cross-env NODE_ENV=development webpack-dev-server --open --hot
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs vuetest
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls vuetest
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

Does anyone know how to fix it please? 有谁知道如何解决它吗?

Do the following navigate into the vuetest directory and first 执行以下操作,首先导航到vuetest目录

npm install

then run npm run dev 然后运行npm run dev

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM