Search code examples
javascriptnode.jsenvironment-variablesnestjstypeorm

How to set up typeorm .env file?


I've created a ormconfig.env file in the nestjs starter project and put the variables from this documentation in there and added this line here

@Module({
  imports: [
    TypeOrmModule.forRoot(),
    TaskModule,
  ],
})
export class AppModule {
}`

And the console shows this error:

Error: EACCES: permission denied, scandir '/Library/Application Support/Apple/AssetCache/Data' at Object.fs.readdirSync (fs.js:904:18)

How should I properly set up typeorm .env file in nestjs?


Solution

  • It seems like node is trying to scan your complete file system for entity files and of course does not have the permissions to do so.

    Make sure that you have a path within your project folder for the TYPEORM_ENTITIES variable.

    For example, look for all files ending with .entity.ts recursively under the project's src folder:

    TYPEORM_ENTITIES = src/**/**.entity.ts