I am struggling to understand why TypeScript is not compiling code from the node_modules
folder.
Below is the content of my tsconfig.json
file:
{
"compilerOptions": {
"rootDir": ".",
"baseUrl": ".",
"paths": {
"shared": ["./src/shared"],
"client": ["./src/client"],
"server": ["./src/server"],
"express": ["./node_modules/express"]
},
"plugins": [
{"transform": "ts-transformer-imports"}
],
"esModuleInterop": true,
"allowJs": true,
"target": "es2015",
"module": "commonjs",
"outDir": "./build"
},
"files": ["./src/server/app.ts"]
}
Within src/server/app.ts
, I have imported both express
and shared
:
import shared from 'shared';
import express from 'express';
After compilation, the code for shared
and server
is generated successfully. However, the code for express
is not being generated. This situation is quite perplexing!
I cannot comprehend why it would choose not to compile code simply because it resides in a directory named node_modules
.
What steps can I take to resolve this issue?
Edit: I attempted to modify the configuration file to
"express/*": ["./node_modules/express/*"]
, but it did not have any impact. (Although I stumbled upon this suggestion online)