dag*_*da1 3 mocha.js typescript ts-node
我有以下项目结构
|_typetests
| |_type.test.ts
|
|
myproj.d.ts
tsconfig.json
Run Code Online (Sandbox Code Playgroud)
我的 tsconfig.json 看起来像这样:
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"lib": [
"es6"
],
"target": "es6",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"types": [
"node",
"mocha"
],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": "./"
},
"include": [
"types/*.test.ts"
],
"exclude": ["node_modules"]
}
Run Code Online (Sandbox Code Playgroud)
如果我跑 ./node_modules/.bin/tsc -p . --traceResolution
然后我可以看到:
模块名称“myproj”已成功解析为“/Users/paulcowan/projects/myproj/myproj.d.ts”。========
但是当我通过 mocha 运行以下内容时
./node_modules/.bin/mocha -r ts-node/register types/*.test.ts
Run Code Online (Sandbox Code Playgroud)
Error: Cannot find module 'myproj'
hoa*_*gdv 14
尝试使用--files标志来解决您的问题。
或将TS_NODE_FILES环境变量设置为true并重试
TS_NODE_FILES=true ./node_modules/.bin/mocha -r ts-node/register types/*.test.ts
| 归档时间: |
|
| 查看次数: |
3194 次 |
| 最近记录: |