I have a Typescript project whose tsconfig.json file currently looks like this:
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "es2020",
"baseUrl": "src",
"outDir": "dist",
"declaration": false,
"sourceMap": true,
"esModuleInterop": true,
"newLine": "lf",
"forceConsistentCasingInFileNames": true,
"strict": true,
"strictNullChecks": true,
"importsNotUsedAsValues": "error",
"isolatedModules": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"preserveConstEnums": true
},
"include": ["src"]
}
When I build my project with tsc no problems arise. But when I run it with node dist/server/index.js I get errors like Cannot find module 'server/foo/bar' MODULE_NOT_FOUND.
What tools do developers have to try to debug this?
TypeScript could find the module during transpilation, otherwise it would have failed. Why can't JavaScript find it then?
How can I know where it tried to look for the module? Or any other information that could help the developer figure out how to fix this.