tsconfig-paths
tsconfig-paths copied to clipboard
Module not found: tsconfig compileOptions.paths are not being resolved
I am not sure whether this is the right place to report this issue:
I am using webpack with ts-node in order to be able to use typescript as a configuration language. I have created a custom tsconfig file for webpack:
// tsconfig.webpack.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"esModuleInterop": true,
"baseUrl": "./",
"paths": {
"CONFIG": ["config/config.ts"]
}
}
}
Everything works fine, except the path aliases are not being resolved when running webpack:
cross-env TS_NODE_PROJECT='tsconfig.webpack.json' webpack --config app/config/webpack/webpack.prod.ts
// Works fine.
import { DIST_ROOT } from '../../../config/config'
// Error: Cannot find module 'CONFIG'
import { DIST_ROOT } from 'CONFIG'
I believe you need ./config/config.ts and not config/config.ts as it would resolve to an npm module without the ./ in the front.