Closed wxs77577 closed 4 years ago
It's not about nestjs-config for sure.
Your entry point is apps/admin/main.js
and the problem is here ...libs/db/src/db.config.ts
So are you sure you compile libs/db/src
folder? I pretty sure you don't
@zMotivat0r Thanks for your reply, but how could I fix it in monorepo mode?
/config/app.ts
export default {
name: 'APP',
secret: process.env.SECRET
}
It throws an error:
C:\work\code\nest-test\config\app.ts:1
export default {
^^^^^^
SyntaxError: Unexpected token export
...
If I move app.ts
to app.js
with module.exports
it works.
module.exports = {
name: 'APP',
secret: process.env.SECRET
}
How could I use typescript
in my configuration files?
What's your config glob? Looks like it's using ts files in prod.
ConfigModule.load(path.resolve('config', '**/!(*.d).{ts,js}'))
@bashleigh
Your path includes every file from where the process is run from Which is not what you want to do because this will include any file ending with .ts
or .js
. It's best to use a relative dir using ___dirname
to only pick the files relative to where your main file is being called. I would use this instead ConfigModule.load(path.resolve(__dirname, 'config', '**/!(*.d).{ts,js}'))
It does not work after I move to monorepo mode: https://docs.nestjs.com/cli/monorepo