Skip to content

Node regression in v22.14.0 resolving ESM module #57011

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

Open
austinw-fineart opened this issue Feb 12, 2025 · 9 comments
Open

Node regression in v22.14.0 resolving ESM module #57011

austinw-fineart opened this issue Feb 12, 2025 · 9 comments

Comments

@austinw-fineart
Copy link

austinw-fineart commented Feb 12, 2025

Version

v22.14.0

Platform

Microsoft Windows NT 10.0.26100.0 x64

Subsystem

No response

What steps will reproduce the bug?

As the bug appears when serving an Nx Angular application there's no simple snippet to contribute.
Instead here's a minimum reproducible project repo: https://github.com/austinw-fineart/org

How often does it reproduce? Is there a required condition?

Always since v22.14.0. Last known good version was v22.13.1.

What is the expected behavior? Why is that the expected behavior?

Regression should not occur

What do you see instead?

Error: No "exports" main defined in C:\Users\Austin\Documents\GitHub\org\node_modules\@jsverse\transloco-keys-manager\package.json
    at exportsNotFound (node:internal/modules/esm/resolve:314:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:604:13)
    at resolveExports (node:internal/modules/cjs/loader:639:36)
    at Function._findPath (node:internal/modules/cjs/loader:728:31)
    at Function.<anonymous> (node:internal/modules/cjs/loader:1211:27)
    at Function.Module._resolveFilename (C:\Users\Austin\Documents\GitHub\org\node_modules\tsconfig-paths\src\register.ts:115:36)
    at Function._load (node:internal/modules/cjs/loader:1055:27)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
    at Module.<anonymous> (node:internal/modules/cjs/loader:1311:12)

Additional information

No response

@joyeecheung
Copy link
Member

Could be related to one of #55543 #56382 or #55412 @aduh95 @JakobJingleheimer

@JakobJingleheimer
Copy link
Member

Also occurs on 23.7.0 (and 23.6.0)

@targos
Copy link
Member

targos commented Feb 13, 2025

Here's how the module defines its exports (source):

  "type": "module",
  "exports": {
    ".": {
      "import": "./public-api.js",
      "types": "./public-api.d.ts"
    },
    "./marker": {
      "import": "./marker.js",
      "types": "./marker.d.ts"
    }
  },

@JakobJingleheimer
Copy link
Member

The error is originating from tsconfig-paths:

https://github.com/dividab/tsconfig-paths/blob/5183c7fc5b0c446cf35c5c3ee8c090631faaeddc/src/register.ts#L99-L116

(which is monkey-patching CJS)

Specifically, a call to Module._resolveFilename

@targos
Copy link
Member

targos commented Feb 13, 2025

I get the same error with a plain require('@jsverse/transloco-keys-manager'), using any supported version of Node.js.

@JakobJingleheimer
Copy link
Member

@targos that "types" key thing seems vaguely familiar. I'm adding a test for unrecognised export keys.

I get the same error with a plain require('@jsverse/transloco-keys-manager'), using any supported version of Node.js.

I believe that is because @jsverse/transloco-keys-manager is using tsconfig-paths.

@JakobJingleheimer
Copy link
Member

I'm adding a test for unrecognised export keys.

It's not the presence of "types" within the export: #57026

@JakobJingleheimer
Copy link
Member

JakobJingleheimer commented Feb 13, 2025

I get the same error with a plain require('@jsverse/transloco-keys-manager'), using any supported version of Node.js.

OH! wait, you mean any LTS version? (I just checked 22.13.1, and it repos there, which means it's not the introduction of findPackageJSON).

[austinw-fineart-org] $ ~/Workspace/github/nodejs/node/node ~/Workspace/github/nodejs/node/deps/npm/bin/npm-cli.js exec nx build org --prod --verbose
npm verbose cli ~/Workspace/github/nodejs/node/out/Release/node ~/Workspace/github/nodejs/node/deps/npm/bin/npm-cli.js
npm info using [email protected]
npm info using [email protected]
npm warn config production Use `--omit=dev` instead.
npm verbose title npm exec nx build org
npm verbose argv "exec" "nx" "build" "org" "--prod" "--loglevel" "verbose"
npm verbose logfile logs-max:10 dir:~/.npm/_logs/2025-02-13T16_04_41_087Z-
npm verbose logfile ~/.npm/_logs/2025-02-13T16_04_41_087Z-debug-0.log

> nx run org:build:production

⠋ Generating browser application bundles (phase: setup)...
 NX   No "exports" main defined in ~/Workspace/playground/austinw-fineart-org/node_modules/@jsverse/transloco-keys-manager/package.json

@austinw-fineart
Copy link
Author

22.13.1 has always worked fine for me but I've tested it on a clean environment just to be sure.

PS C:\Users\WDAGUtilityAccount\Desktop\org-main> C:\Users\WDAGUtilityAccount\Downloads\node-v22.13.1-win-x64\node-v22.13.1-win-x64\npm.cmd exec nx build org --prod --verbose
npm verbose cli C:\Users\WDAGUtilityAccount\Downloads\node-v22.13.1-win-x64\node-v22.13.1-win-x64\node.exe C:\Users\WDAGUtilityAccount\Downloads\node-v22.13.1-win-x64\node-v22.13.1-win-x64\node_modules\npm\bin\npm-cli.js
npm info using [email protected]
npm info using [email protected]
npm warn config production Use `--omit=dev` instead.
npm verbose title npm exec nx build org
npm verbose argv "exec" "nx" "build" "org" "--prod" "--loglevel" "verbose"
npm verbose logfile logs-max:10 dir:C:\Users\WDAGUtilityAccount\AppData\Local\npm-cache\_logs\2025-02-13T17_28_27_811Z-
npm verbose logfile C:\Users\WDAGUtilityAccount\AppData\Local\npm-cache\_logs\2025-02-13T17_28_27_811Z-debug-0.log

> nx run org:build:production

- Generating browser application bundles (phase: setup)...
(node:8848) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
√ Browser application bundle generation complete.
√ Browser application bundle generation complete.
- Copying assets...
√ Copying assets complete.
- Generating index html...
√ Index html generation complete.

Initial chunk files           | Names         |  Raw size | Estimated transfer size
main.39d28c4b8ee6fbc9.js      | main          | 211.70 kB |                56.90 kB
polyfills.9e1e1976f7506f11.js | polyfills     |  34.77 kB |                11.35 kB
runtime.9623f3ca9db77b16.js   | runtime       | 884 bytes |               512 bytes
styles.ef46db3751d8e999.css   | styles        |   0 bytes |                       -

                              | Initial total | 247.35 kB |                68.76 kB

Build at: 2025-02-13T17:28:34.107Z - Hash: d907fffc9ffe2565 - Time: 1915ms

Warning: C:/Users/WDAGUtilityAccount/Desktop/org-main/apps/org/src/app/nx-welcome.component.ts-angular-inline--1.css exceeded maximum budget. Budget 4.00 kB was not met by 3.03 kB with a total of 7.03 kB.



———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Successfully ran target build for project org (5s)

npm verbose cwd C:\Users\WDAGUtilityAccount\Desktop\org-main
npm verbose os Windows_NT 10.0.26100
npm verbose node v22.13.1
npm verbose npm  v10.9.2
npm verbose exit 0
npm info ok

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

4 participants