本文介绍了适用于vue-cli的Webpack开发服务器:错误生成EACCES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的环境:
- 通过VirtualBox(安装在Windows7上)的Centos7
- 节点版本: 6.10.3
- Npm版本:3.10.10
- 我落后于公司代理人
- Centos7 via VirtualBox (installed on Windows7)
- Node version: 6.10.3
- Npm version : 3.10.10
- I'm behind a corporate proxy
我用vue-cli初始化了一个新项目 vuetest,现在我想运行一个webpack服务器。
我使用以下命令:
I initialized a new project "vuetest" with vue-cli, and now I want to run a webpack server.I use the following command:
npm run dev
此命令等效于 webpack-dev-server --open --hot,这是我要检查的 package.json文件:
This command is equivalent to "webpack-dev-server --open --hot", here is my "package.json" file to check:
{
"name": "vuetest",
"description": "A Vue.js project",
"version": "1.0.0",
"author": "",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"vue": "^2.3.3"
},
"devDependencies": {
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-preset-env": "^1.5.1",
"cross-env": "^3.2.4",
"css-loader": "^0.25.0",
"file-loader": "^0.9.0",
"vue-loader": "^12.1.0",
"vue-template-compiler": "^2.3.3",
"webpack": "^2.6.1",
"webpack-dev-server": "^2.4.5"
}
}
但是我收到以下错误:
> [email protected] dev /var/www/html/vuetest
> cross-env NODE_ENV=development webpack-dev-server --open --hot
Project is running at http://localhost:8080/
webpack output is served from /dist/
404s will fallback to /index.html
internal/child_process.js:319
throw errnoException(err, 'spawn');
^
Error: spawn EACCES
at exports._errnoException (util.js:1018:11)
at ChildProcess.spawn (internal/child_process.js:319:11)
at Object.exports.spawn (child_process.js:378:9)
at module.exports (/var/www/html/vuetest/node_modules/opn/index.js:75:24)
at reportReadiness (/var/www/html/vuetest/node_modules/webpack-dev-server/bin/webpack-dev-server.js:424:3)
at Server.<anonymous> (/var/www/html/vuetest/node_modules/webpack-dev-server/bin/webpack-dev-server.js:404:4)
at Server.g (events.js:292:16)
at emitNone (events.js:86:13)
at Server.emit (events.js:185:7)
at emitListeningNT (net.js:1284:10)
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! [email protected] dev: `cross-env NODE_ENV=development webpack-dev-server --open --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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 ERR! Please include the following file with any support request:
npm ERR! /var/www/html/vuetest/npm-debug.log
以下是 npm的内容-debug.log文件:
Here's the contents of the "npm-debug.log" file:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'dev' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle [email protected]~predev: [email protected]
6 silly lifecycle [email protected]~predev: no script for predev, continuing
7 info lifecycle [email protected]~dev: [email protected]
8 verbose lifecycle [email protected]~dev: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~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 [email protected]~dev: CWD: /var/www/html/vuetest
11 silly lifecycle [email protected]~dev: Args: [ '-c',
11 silly lifecycle 'cross-env NODE_ENV=development webpack-dev-server --open --hot' ]
12 silly lifecycle [email protected]~dev: Returned: code: 1 signal: null
13 info lifecycle [email protected]~dev: Failed to exec dev script
14 verbose stack Error: [email protected] 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 [email protected]
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 [email protected] dev: `cross-env NODE_ENV=development webpack-dev-server --open --hot`
22 error Exit status 1
23 error Failed at the [email protected] 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?
推荐答案
我找到了解决方案。
在 package.json文件中,我替换为:
I found the solution.In the "package.json" file, I replaced:
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot"
通过此:
"dev": "cross-env NODE_ENV=development webpack-dev-server --port 8080 --hot --host 0.0.0.0"
现在一切正常,我的服务器正常启动。
And now everything works, my server, starts up normally.
这篇关于适用于vue-cli的Webpack开发服务器:错误生成EACCES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!