【发布时间】:2021-07-16 16:22:54
【问题描述】:
我在使用 typescript 编译时遇到问题。我正在尝试在 docker 容器中运行它,但即使在本地运行也会产生相同的错误,所以我认为我搞砸了参数。我需要使用节点运行。
我正在尝试运行
node --nolazy -r ./node_modules/tsconfig-paths/register.js -r ./node_modules/ts-node/register ./node_modules/jest/bin/jest.js
哪个输出
TypeError: Cannot read property 'alias' of undefined
at /home/user/Workspace/project/node_modules/jest-validate/build/validateCLIOptions.js:97:58
at Array.reduce (<anonymous>)
at validateCLIOptions (/home/user/Workspace/project/node_modules/jest-validate/build/validateCLIOptions.js:96:47)
at buildArgv (/home/user/Workspace/project/node_modules/jest/node_modules/jest-cli/build/cli/index.js:192:42)
at Object.run (/home/user/Workspace/project/node_modules/jest/node_modules/jest-cli/build/cli/index.js:155:18)
at Object.<anonymous> (/home/user/Workspace/project/node_modules/jest/node_modules/jest-cli/bin/jest.js:16:27)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
at node:internal/modules/cjs/loader:1121:10
at Object..js (/home/user/Workspace/project/node_modules/ts-node/src/index.ts:1045:43)
at Module.load (node:internal/modules/cjs/loader:972:32)
如果我尝试使用我的 Jest 配置,我会得到一个不同的错误
node --nolazy -r ./node_modules/tsconfig-paths/register.js -r ./node_modules/ts-node/register ./node_modules/jest/bin/jest.js --config=./jest-config.json
哪个输出
Usage: jest.js [--config=<pathToConfigFile>] [TestPathPattern]
Options:
...[Jest help output]...
(0 , _jestConfig(...).isJSONString) is not a function
似乎tsconfig-paths 导致了这个问题,因为当我删除它时测试开始运行,但它们当然会失败,因为节点需要的是 javascript 而不是 typescript
【问题讨论】:
标签: node.js typescript jestjs