Skip to content

Bun run not load config value #516

Description

@fm39hz

after build into .js file, the config loader became unreliable as it still recognize the variable, but load everything into undefined

$ bun dist/main.js
[Nest] 1160606  - 07/30/2025, 4:25:40 PM   DEBUG [ConfigLoader] Successful loaded key: SERVER__HOST_NAME
[Nest] 1160606  - 07/30/2025, 4:25:40 PM   DEBUG [ConfigLoader] Successful loaded key: SERVER__GLOBAL_PREFIX
[Nest] 1160606  - 07/30/2025, 4:25:40 PM   DEBUG [ConfigLoader] Successful loaded key: SERVER__NETWORK_SCHEMA
[Nest] 1160606  - 07/30/2025, 4:25:40 PM   DEBUG [ConfigLoader] Successful loaded key: SERVER__PORT
[Nest] 1160606  - 07/30/2025, 4:25:40 PM   DEBUG [ConfigLoader] Successful loaded key: SERVER__API_VERSION
[Nest] 1160606  - 07/30/2025, 4:25:40 PM   DEBUG [ConfigLoader] Successful loaded key: SWAGGER__PREFIX
[Nest] 1160606  - 07/30/2025, 4:25:40 PM   DEBUG [ConfigLoader] Successful loaded key: FIREBASE__PROJECT_ID
[Nest] 1160606  - 07/30/2025, 4:25:40 PM   DEBUG [ConfigLoader] Successful loaded key: FIREBASE__PRIVATE_KEY
[Nest] 1160606  - 07/30/2025, 4:25:40 PM   DEBUG [ConfigLoader] Successful loaded key: FIREBASE__CLIENT_EMAIL
[Nest] 1160606  - 07/30/2025, 4:25:40 PM   DEBUG [ConfigLoader] Successful loaded key: MONGO__URI
115 |         });
116 |         // defaults to strictest validation rules
117 |         const schemaErrors = (0, imports_util_1.validateSync)(config, Object.assign({ forbidUnknownValues: true, whitelist: true }, options));
118 |         if (schemaErrors.length > 0) {
119 |             const configErrorMessage = this.getConfigErrorMessage(schemaErrors);
120 |             throw new Error(configErrorMessage);
                        ^
error: Configuration is not valid:
  - config server.undefined does not match the following rules:
    - unknownValue: an unknown value was passed to the validate function, current config is `undefined`
  - config swagger.undefined does not match the following rules:
    - unknownValue: an unknown value was passed to the validate function, current config is `undefined`
  - config firebase.undefined does not match the following rules:
    - unknownValue: an unknown value was passed to the validate function, current config is `undefined`
  - config mongo.undefined does not match the following rules:
    - unknownValue: an unknown value was passed to the validate function, current config is `undefined`

      at validateWithClassValidator (/home/fm39hz/Workspace/Eatsy/eatsy-kam-ai/node_modules/nest-typed-config/dist/typed-config.module.js:120:19)
      at getDynamicModule (/home/fm39hz/Workspace/Eatsy/eatsy-kam-ai/node_modules/nest-typed-config/dist/typed-config.module.js:47:24)
      at <anonymous> (/home/fm39hz/Workspace/Eatsy/eatsy-kam-ai/dist/domain/app/app.metadata.js:20:44)
      at <anonymous> (/home/fm39hz/Workspace/Eatsy/eatsy-kam-ai/dist/domain/app/app.module.js:12:7)
      at <anonymous> (/home/fm39hz/Workspace/Eatsy/eatsy-kam-ai/dist/main.js:13:7)

Bun v1.2.19 (Linux x64)
error: script "start:prod" exited with code 1

the problem is not there with start from nest

$ nest start --watch
>  SWC  Running...
Successfully compiled: 32 files with swc (100.15ms)
Watching for file changes.
[Nest] 1160391  - 07/30/2025, 4:25:35 PM   DEBUG [ConfigLoader] Successful loaded key: SERVER__HOST_NAME
[Nest] 1160391  - 07/30/2025, 4:25:35 PM   DEBUG [ConfigLoader] Successful loaded key: SERVER__GLOBAL_PREFIX
[Nest] 1160391  - 07/30/2025, 4:25:35 PM   DEBUG [ConfigLoader] Successful loaded key: SERVER__NETWORK_SCHEMA
[Nest] 1160391  - 07/30/2025, 4:25:35 PM   DEBUG [ConfigLoader] Successful loaded key: SERVER__PORT
[Nest] 1160391  - 07/30/2025, 4:25:35 PM   DEBUG [ConfigLoader] Successful loaded key: SERVER__API_VERSION
[Nest] 1160391  - 07/30/2025, 4:25:35 PM   DEBUG [ConfigLoader] Successful loaded key: SWAGGER__PREFIX
[Nest] 1160391  - 07/30/2025, 4:25:35 PM   DEBUG [ConfigLoader] Successful loaded key: FIREBASE__PROJECT_ID
[Nest] 1160391  - 07/30/2025, 4:25:35 PM   DEBUG [ConfigLoader] Successful loaded key: FIREBASE__PRIVATE_KEY
[Nest] 1160391  - 07/30/2025, 4:25:35 PM   DEBUG [ConfigLoader] Successful loaded key: FIREBASE__CLIENT_EMAIL
[Nest] 1160391  - 07/30/2025, 4:25:35 PM   DEBUG [ConfigLoader] Successful loaded key: MONGO__URI
[Nest] 1160391  - 07/30/2025, 4:25:35 PM     LOG [NestFactory] Starting Nest application... +109ms
[Nest] 1160391  - 07/30/2025, 4:25:35 PM     LOG [InstanceLoader] AppModule dependencies initialized +19ms
[Nest] 1160391  - 07/30/2025, 4:25:35 PM     LOG [InstanceLoader] TypedConfigModule dependencies initialized +1ms
[Nest] 1160391  - 07/30/2025, 4:25:35 PM     LOG [InstanceLoader] SwaggerModule dependencies initialized +0ms
[Nest] 1160391  - 07/30/2025, 4:25:35 PM     LOG [InstanceLoader] FirebaseModule dependencies initialized +0ms
[Nest] 1160391  - 07/30/2025, 4:25:35 PM     LOG [InstanceLoader] MongoModule dependencies initialized +0ms
[Nest] 1160391  - 07/30/2025, 4:25:35 PM     LOG [InstanceLoader] MongooseModule dependencies initialized +0ms
[Nest] 1160391  - 07/30/2025, 4:25:35 PM     LOG [InstanceLoader] HttpModule dependencies initialized +27ms
[Nest] 1160391  - 07/30/2025, 4:25:35 PM     LOG [InstanceLoader] TerminusModule dependencies initialized +0ms
[Nest] 1160391  - 07/30/2025, 4:25:35 PM     LOG [InstanceLoader] ServerModule dependencies initialized +1ms

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions