mongoose-tsgen
mongoose-tsgen copied to clipboard
how to get typescript path alias working?
I'm using tsc-alias
for alias path in my express application, and when i tried to run mtgen command
. it gives this error:
Generating mongoose typescript definitions... !
Error: Cannot find module 'src/libs/errors'
Require stack:
- /Users/m5kev4n/Works/Served/served/apps/api/src/db/schemas.ts
- /Users/m5kev4n/Works/Served/served/node_modules/mongoose-tsgen/lib/helpers/parser.js
- /Users/m5kev4n/Works/Served/served/node_modules/mongoose-tsgen/lib/index.js
- /Users/m5kev4n/Works/Served/served/node_modules/mongoose-tsgen/bin/run
Code: MODULE_NOT_FOUND
My tsconfig.json
:
"compilerOptions": {
"rootDir": ".",
"outDir": "dist",
"baseUrl": "./"
},
My schemas.ts:
import { ERRORS } from 'src/libs/errors' // if i change to '../libs/errors' it works
const customerSchema: CustomerSchema = new Schema({...})
is there any config i can set for mtgen
to work with this path alias?
Hi @Mike-Van, this tool has not been tested with tsc-alias
, so its unlikely to work. Instead, you can use the paths field in tsconfig.json
.
Let me know if that resolves the issue for you!
@Mike-Van Checking in on my last reply, will close this off soon if I dont hear back