【发布时间】:2018-11-29 09:56:55
【问题描述】:
我为 vue 创建了一个客户端项目并运行 npm run serve, 但出现此错误:
尝试重新安装 node、npm,编辑了一些 PATH,但没有任何效果
版本
3.2.1
节点和操作系统信息
节点 v10.14.0/npm 6.4.1
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'serve' ]
2 info using npm@6.4.1
3 info using node@v10.14.0
4 verbose run-script [ 'preserve', 'serve', 'postserve' ]
5 info lifecycle client@0.1.0~preserve: client@0.1.0
6 info lifecycle client@0.1.0~serve: client@0.1.0
7 verbose lifecycle client@0.1.0~serve: unsafe-perm in lifecycle true
8 verbose lifecycle client@0.1.0~serve: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/alexsexotic/Desktop/work/Test - mongod:node/client/node_modules/.bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Users/alexsexotic/.npm-global/bin
9 verbose lifecycle client@0.1.0~serve: CWD: /Users/alexsexotic/Desktop/work/Test - mongod:node/client
10 silly lifecycle client@0.1.0~serve: Args: [ '-c', 'vue-cli-service serve' ]
11 info lifecycle client@0.1.0~serve: Failed to exec serve script
12 verbose stack Error: client@0.1.0 serve: `vue-cli-service serve`
12 verbose stack spawn ENOENT
12 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
12 verbose stack at ChildProcess.emit (events.js:182:13)
12 verbose stack at maybeClose (internal/child_process.js:962:16)
12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
13 verbose pkgid client@0.1.0
14 verbose cwd /Users/alexsexotic/Desktop/work/Test - mongod:node/client
15 verbose Darwin 17.2.0
16 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "serve"
17 verbose node v10.14.0
18 verbose npm v6.4.1
19 error file sh
20 error code ELIFECYCLE
21 error errno ENOENT
22 error syscall spawn
23 error client@0.1.0 serve: `vue-cli-service serve`
23 error spawn ENOENT
24 error Failed at the client@0.1.0 serve script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]
【问题讨论】:
-
把你的问题美化一点,把更多的细节放在一边
-
向我们展示你的 package.json,看看“scripts”字段中是否有“serve”
-
@javimovi 给你 { "name": "client", "version": "0.1.0", "private": true, "scripts": { "serve": "vue- cli-service serve", "build": "vue-cli-service build", "lint": "vue-cli-service lint" },
-
你能运行
npx serve看看它是否有效吗? -
@Aer0 哇,它有点工作,但我的 index.hmtl 没有加载,请问您如何看待这个解决方案?我搜索了很多论坛,但没有人为我解决。
标签: vue.js