我无法在NX工作区内的Express应用程序中导入任何.json文件. 这是我的导入声明
import swaggerDocument from '../swagger.json';
和我的项目 struct
tsconfig.base.json
apps
|- test-app
|- swagger.json
|- tsconfig.json
|- tsconfig.app.json
|- src
|- main.ts <-- import statement here
这是我的tsconfig.base.json
美元
{
"compileOnSave": false,
"compilerOptions": {
"rootDir": ".",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"module": "esnext",
"lib": ["es2020", "dom"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
...paths for other modules
},
"strict": true
},
"exclude": ["node_modules", "tmp"]
}
tsconfig.json
个
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"esModuleInterop": true,
"resolveJsonModule": true
}
}
和tsconfig.app.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["node"],
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}
那么我到底做错了什么呢?我还try 将.json文件放在/src目录中并从那里导入,但没有成功.