By including the line "resolveJsonModule": true
in my project's .tsconfig file, I have successfully implemented direct importing of data from .json files. The project functions properly, even when using nodemon.
However, upon building the project and compiling all files into a "dist" folder, running node dist/index.js
results in failure when it encounters the json import. It seems that the actual build command used is:
babel src --out-dir dist --extensions .js,.ts --source-maps
This project is for server-side development and does not involve webpack.
Here is the tsconfig file as requested:
{
"compilerOptions": {
"baseUrl": ".",
"typeRoots": ["./types"],
"target": "es6",
"module": "es6",
"declaration": true,
"outDir": "dist",
"strict": true ,
"noImplicitAny": true,
"strictNullChecks": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"resolveJsonModule": true
}
}