gpt4 book ai didi

javascript - Jest js node_modules\jest\node_modules\jest-cli\build\cli\index.js :227 } catch {

转载 作者:行者123 更新时间:2023-12-03 15:47:59 29 4
gpt4 key购买 nike

我跑npm init npm i -D jest像这样 tutorial
运行推荐 nmp test 后出现此错误
这不是生物.js 或生物.test.js 的错误,因为没有发生此文件错误。我怎样才能解决这个问题 ?我已经尝试恢复 mode_modules。我不知道这有什么问题,但我使用的是节点 8.17.0,因为我正在使用 Firebase 云功能

PS C:\Users\Pawel\Desktop\HerosIIIJS> npm test

> heros_iii_js@1.0.0 test C:\Users\Pawel\Desktop\HerosIIIJS
> jest

C:\Users\Pawel\Desktop\HerosIIIJS\node_modules\jest\node_modules\jest-cli\build\cli\index.js:227
} catch {
^

SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\Pawel\Desktop\HerosIIIJS\node_modules\jest\node_modules\jest-cli\bin\jest.js:16:3)
npm ERR! Test failed. See above for more details.
const getProjectListFromCLIArgs = (argv, project) => {
const projects = argv.projects ? argv.projects : [];

if (project) {
projects.push(project);
}

if (!projects.length && process.platform === 'win32') {
try {
projects.push((0, _jestUtil().tryRealpath)(process.cwd()));
} catch { // <= error
// do nothing, just catch error
// process.binding('fs').realpath can throw, e.g. on mapped drives
}
}

if (!projects.length) {
projects.push(process.cwd());
}

return projects;
};
包.json
{
"name": "heros_iii_js",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
},
"author": "",
"license": "ISC",
"devDependencies": {
"jest": "^26.6.2"
}
}

文件结构:
![enter image description here

最佳答案

升级 node.js
在旧版本的节点中,他们没有处理 jest 文件的 catch block 。
它将从 node -v9.11.2 到等等。

关于javascript - Jest js node_modules\jest\node_modules\jest-cli\build\cli\index.js :227 } catch {,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64660449/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com