"vue-cli-service test:unit "运行成功;但是 npm 退出错误代码 1 ELIFECYCLE
"vue-cli-service test:unit " runs succesfully; but npm exits err code 1 ELIFECYCLE
我正在尝试 运行 npm run test:unit
,真正的错误似乎是来自 npm debug.log 的 test:unit: Failed to exec test:unit script
。然而脚本 运行 并且执行没有问题。
我对 NPM + Node 有点陌生,所以我正在为这种行为而苦苦挣扎。当我 运行 npm run test:unit
( Package.json 中的 "test:unit": "vue-cli-service test:unit"
)我得到这个输出:
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 1 file obsolete, 0 total
Time: 1.208s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cheatsheet@0.1.0 test:unit: `vue-cli-service test:unit`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cheatsheet@0.1.0 test:unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/max/.npm/_logs/2020-03-26T18_16_36_155Z-debug.log
预期结果
测试应该刚刚通过,我不应该看到 NPM/Node 崩溃。
运行 ./node_modules/.bin/vue-cli-service test:unit
我只得到测试和 Jest 输出。一切都按预期工作。那么我的设置出了什么问题?
已尝试解决
- 重新安装node_modules
- 更新了 npm
- 更新为node:stable
- 重新安装 nvm(节点版本管理器)并更新
- 尝试向 vue-cli-service 添加额外的调试标志
npm_debug.log
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/home/max/.nvm/versions/node/v13.11.0/bin/node',
1 verbose cli '/home/max/.nvm/versions/node/v13.11.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'test:unit'
1 verbose cli ]
2 info using npm@6.14.4
3 info using node@v13.11.0
4 verbose run-script [ 'pretest:unit', 'test:unit', 'posttest:unit' ]
5 info lifecycle cheatsheet@0.1.0~pretest:unit: cheatsheet@0.1.0
6 info lifecycle cheatsheet@0.1.0~test:unit: cheatsheet@0.1.0
7 verbose lifecycle cheatsheet@0.1.0~test:unit: unsafe-perm in lifecycle true
8 verbose lifecycle cheatsheet@0.1.0~test:unit: PATH: /home/max/.nvm/versions/node/v13.11.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/max/cheatsheet_project/cheatsheet/node_modules/.bin:/home/max/.pyenv/plugins/pyenv-virtualenv/shims:/home/max/.pyenv/shims:~/.pyenv/bin:/home/max/Maven/apache-maven-3.5.2/bin:/home/max/.nvm/versions/node/v13.11.0/bin:/home/max/.rbenv/shims:/home/max/.rbenv/bin:/home/max/workspace/go/bin:/home/max/.cargo/bin:/home/max/.cargo/bin:/home/max/bin:/home/max/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-9-oracle/bin:/usr/lib/jvm/java-9-oracle/db/bin:/usr/lib/jvm/java-9-oracle/bin:/usr/lib/jvm/java-9-oracle/db/bin:/usr/local/go/bin
9 verbose lifecycle cheatsheet@0.1.0~test:unit: CWD: /home/max/cheatsheet_project/cheatsheet
10 silly lifecycle cheatsheet@0.1.0~test:unit: Args: [ '-c', 'vue-cli-service test:unit' ]
11 silly lifecycle cheatsheet@0.1.0~test:unit: Returned: code: 1 signal: null
12 info lifecycle cheatsheet@0.1.0~test:unit: Failed to exec test:unit script
13 verbose stack Error: cheatsheet@0.1.0 test:unit: `vue-cli-service test:unit`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/home/max/.nvm/versions/node/v13.11.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess.<anonymous> (/home/max/.nvm/versions/node/v13.11.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1026:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid cheatsheet@0.1.0
15 verbose cwd /home/max/cheatsheet_project/cheatsheet
16 verbose Linux 4.15.0-91-generic
17 verbose argv "/home/max/.nvm/versions/node/v13.11.0/bin/node" "/home/max/.nvm/versions/node/v13.11.0/bin/npm" "run" "test:unit"
18 verbose node v13.11.0
19 verbose npm v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error cheatsheet@0.1.0 test:unit: `vue-cli-service test:unit`
22 error Exit status 1
23 error Failed at the cheatsheet@0.1.0 test:unit script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
./node_modules/.bin/vue-cli-service test:unit -u
修复了这个问题。这是 jest --updatesnapshot
的 shorthand 命令。
Since we just updated our component to point to a different address, it's reasonable to expect changes in the snapshot for this component. Our snapshot test case is failing because the snapshot for our updated component no longer matches the snapshot artifact for this test case.
To resolve this, we will need to update our snapshot artifacts. You can run Jest with a flag that will tell it to re-generate snapshots...
- From Snapshot Testing.
观察到关于快照的错误:
Snapshots: 1 file obsolete, 0 total
不确定为什么这会导致 NPM 错误,但 -u
清除了它,我再也没有看到它。
我正在尝试 运行 npm run test:unit
,真正的错误似乎是来自 npm debug.log 的 test:unit: Failed to exec test:unit script
。然而脚本 运行 并且执行没有问题。
我对 NPM + Node 有点陌生,所以我正在为这种行为而苦苦挣扎。当我 运行 npm run test:unit
( Package.json 中的 "test:unit": "vue-cli-service test:unit"
)我得到这个输出:
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 1 file obsolete, 0 total
Time: 1.208s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cheatsheet@0.1.0 test:unit: `vue-cli-service test:unit`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cheatsheet@0.1.0 test:unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/max/.npm/_logs/2020-03-26T18_16_36_155Z-debug.log
预期结果 测试应该刚刚通过,我不应该看到 NPM/Node 崩溃。
运行 ./node_modules/.bin/vue-cli-service test:unit
我只得到测试和 Jest 输出。一切都按预期工作。那么我的设置出了什么问题?
已尝试解决
- 重新安装node_modules
- 更新了 npm
- 更新为node:stable
- 重新安装 nvm(节点版本管理器)并更新
- 尝试向 vue-cli-service 添加额外的调试标志
npm_debug.log
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/home/max/.nvm/versions/node/v13.11.0/bin/node',
1 verbose cli '/home/max/.nvm/versions/node/v13.11.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'test:unit'
1 verbose cli ]
2 info using npm@6.14.4
3 info using node@v13.11.0
4 verbose run-script [ 'pretest:unit', 'test:unit', 'posttest:unit' ]
5 info lifecycle cheatsheet@0.1.0~pretest:unit: cheatsheet@0.1.0
6 info lifecycle cheatsheet@0.1.0~test:unit: cheatsheet@0.1.0
7 verbose lifecycle cheatsheet@0.1.0~test:unit: unsafe-perm in lifecycle true
8 verbose lifecycle cheatsheet@0.1.0~test:unit: PATH: /home/max/.nvm/versions/node/v13.11.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/max/cheatsheet_project/cheatsheet/node_modules/.bin:/home/max/.pyenv/plugins/pyenv-virtualenv/shims:/home/max/.pyenv/shims:~/.pyenv/bin:/home/max/Maven/apache-maven-3.5.2/bin:/home/max/.nvm/versions/node/v13.11.0/bin:/home/max/.rbenv/shims:/home/max/.rbenv/bin:/home/max/workspace/go/bin:/home/max/.cargo/bin:/home/max/.cargo/bin:/home/max/bin:/home/max/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-9-oracle/bin:/usr/lib/jvm/java-9-oracle/db/bin:/usr/lib/jvm/java-9-oracle/bin:/usr/lib/jvm/java-9-oracle/db/bin:/usr/local/go/bin
9 verbose lifecycle cheatsheet@0.1.0~test:unit: CWD: /home/max/cheatsheet_project/cheatsheet
10 silly lifecycle cheatsheet@0.1.0~test:unit: Args: [ '-c', 'vue-cli-service test:unit' ]
11 silly lifecycle cheatsheet@0.1.0~test:unit: Returned: code: 1 signal: null
12 info lifecycle cheatsheet@0.1.0~test:unit: Failed to exec test:unit script
13 verbose stack Error: cheatsheet@0.1.0 test:unit: `vue-cli-service test:unit`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/home/max/.nvm/versions/node/v13.11.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess.<anonymous> (/home/max/.nvm/versions/node/v13.11.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1026:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid cheatsheet@0.1.0
15 verbose cwd /home/max/cheatsheet_project/cheatsheet
16 verbose Linux 4.15.0-91-generic
17 verbose argv "/home/max/.nvm/versions/node/v13.11.0/bin/node" "/home/max/.nvm/versions/node/v13.11.0/bin/npm" "run" "test:unit"
18 verbose node v13.11.0
19 verbose npm v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error cheatsheet@0.1.0 test:unit: `vue-cli-service test:unit`
22 error Exit status 1
23 error Failed at the cheatsheet@0.1.0 test:unit script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
./node_modules/.bin/vue-cli-service test:unit -u
修复了这个问题。这是 jest --updatesnapshot
的 shorthand 命令。
Since we just updated our component to point to a different address, it's reasonable to expect changes in the snapshot for this component. Our snapshot test case is failing because the snapshot for our updated component no longer matches the snapshot artifact for this test case.
To resolve this, we will need to update our snapshot artifacts. You can run Jest with a flag that will tell it to re-generate snapshots... - From Snapshot Testing.
观察到关于快照的错误:
Snapshots: 1 file obsolete, 0 total
不确定为什么这会导致 NPM 错误,但 -u
清除了它,我再也没有看到它。