typescript - Lỗi: Không thể tìm thấy module '../swagger.json' trong workspace NX
Tôi không thể nhập bất kỳ tệp .json nào trong ứng dụng express của mình bên trong workspace NX. Đây là câu lệnh nhập của tôi
import swaggerDocument from '../swagger.json';
và cấu trúc dự án của tôi
tsconfig.base.json
apps
|- test-app
|- swagger.json
|- tsconfig.json
|- tsconfig.app.json
|- src
|- main.ts <-- import statement here
đây là tsconfig.base.json của tôi
{
"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
}
}
và 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"]
}
Vậy tôi đang làm sai điều gì ở đây? Tôi cũng đã thử đặt tệp .json vào thư mục /src và nhập từ đó, nhưng không thành công.