Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project breaks after updating ts version (using .cjs config files) #754

Open
shaniqwa opened this issue Dec 27, 2023 · 0 comments
Open

Project breaks after updating ts version (using .cjs config files) #754

shaniqwa opened this issue Dec 27, 2023 · 0 comments

Comments

@shaniqwa
Copy link

Describe the bug
When I try to update TypeScript version > 4.1.5, (specifically I tried 4.9.5) I see this error:

gordon_server_1        |
gordon_server_1        | Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/user/src/app/dist/config' is not supported resolving ES modules imported from /user/src/app/dist/src/server.js
gordon_server_1        |     at new NodeError (node:internal/errors:405:5)
gordon_server_1        |     at finalizeResolution (node:internal/modules/esm/resolve:218:17)
gordon_server_1        |     at moduleResolve (node:internal/modules/esm/resolve:838:10)
gordon_server_1        |     at defaultResolve (node:internal/modules/esm/resolve:1036:11)
gordon_server_1        |     at DefaultModuleLoader.resolve (node:internal/modules/esm/loader:251:12)
gordon_server_1        |     at DefaultModuleLoader.getModuleJob (node:internal/modules/esm/loader:140:32)
gordon_server_1        |     at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:33)
gordon_server_1        |     at link (node:internal/modules/esm/module_job:75:36) {
gordon_server_1        |   code: 'ERR_UNSUPPORTED_DIR_IMPORT',
gordon_server_1        |   url: 'file:///user/src/app/dist/config'
gordon_server_1        | }
gordon_server_1        |
gordon_server_1        | Node.js v20.5.1

My project used "type": "module" in package.json and I use .cjs files for the configurations.
This issue is holding me back from major updates to other dependencies, any help to figure this out would be much appreciated.

Expected behavior
I expect everything to continue to work after the TS version update.

Please tell us about your environment:

  • node-config version: 3.3.9
  • node-version: 20.5.1

Other information

When I run in dev mode using ts-node, it works. But after TS transpile to js, it doesn't work.

"start": "NODE_ENV=prod node --experimental-specifier-resolution=node dist/src/server.js",
"dev": "NODE_ENV=dev  node --experimental-specifier-resolution=node --loader ts-node/esm src/server.ts",
      ```
@shaniqwa shaniqwa changed the title Project breaks after updating ts version + using .cjs config files Project breaks after updating ts version (using .cjs config files) Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant