我有以下项目结构
|_typetests
| |_type.test.ts
|
|
myproj.d.ts
tsconfig.json
我的 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"]
}
如果我跑./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
Error: Cannot find module 'myproj'