node icon indicating copy to clipboard operation
node copied to clipboard

module: add `findPackageJSON` util

Open JakobJingleheimer opened this issue 1 year ago • 13 comments

https://github.com/nodejs/node/pull/55229 was too controversial, so back to the original idea from https://github.com/nodejs/node/pull/55173.

Closes https://github.com/nodejs/node/pull/55229

JakobJingleheimer avatar Oct 16 '24 20:10 JakobJingleheimer

Review requested:

  • [ ] @nodejs/loaders

nodejs-github-bot avatar Oct 16 '24 20:10 nodejs-github-bot

so is this basically just https://www.npmjs.com/package/find-pkg / https://www.npmjs.com/package/pkg-up / https://www.npmjs.com/package/package-up ?

ljharb avatar Oct 16 '24 21:10 ljharb

"Just" seems a little dismissive 😕

The first package was last updated 7 years ago (so it may well be outdated, plus its cited limitations).

The second package is deprecated.

The third is maybe similar/close; it appears to only do direct path manipulation and won't respect module resolution (ex from a loader hook), which this does respect.

Edit: looking closer, the third package has several limitations that this does not, such how it handles relative search (cwd vs current module location) and, AFAICS, it does not handle node_modules.

This package is also leveraging/mirroring node's internals, so it will behave exactly as node is doing internally (whereas userland may not, and would have to re-invent the wheel to do so).

JakobJingleheimer avatar Oct 16 '24 21:10 JakobJingleheimer

apologies, you're right, a better way to phrase it is "is this the same capability as these packages".

Certainly doing this internally in node is better for tons of reasons, and I'm glad you're adding it :-) I wanted to confirm what the semantics were, is all.

ljharb avatar Oct 16 '24 21:10 ljharb

I wanted to confirm what the semantics were, is all.

Ah, yes then 🙂

JakobJingleheimer avatar Oct 16 '24 21:10 JakobJingleheimer

The markdown linter is complaining about a codeblock that has no language. It's a directory listing—language is not applicable (it just needs the default codeblock treatment).

Can I disable the rule for that block?

JakobJingleheimer avatar Oct 16 '24 21:10 JakobJingleheimer

can you tag it as sh?

ljharb avatar Oct 16 '24 21:10 ljharb

Codecov Report

Attention: Patch coverage is 98.80478% with 3 lines in your changes missing coverage. Please review.

Project coverage is 88.41%. Comparing base (53b1050) to head (ba9acf9). Report is 686 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/modules/package_json_reader.js 99.08% 2 Missing :warning:
lib/internal/modules/cjs/loader.js 90.90% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #55412      +/-   ##
==========================================
- Coverage   88.42%   88.41%   -0.01%     
==========================================
  Files         654      654              
  Lines      187552   187657     +105     
  Branches    36087    36117      +30     
==========================================
+ Hits       165839   165919      +80     
- Misses      14950    14972      +22     
- Partials     6763     6766       +3     
Files with missing lines Coverage Δ
lib/internal/modules/esm/resolve.js 96.17% <100.00%> (-0.16%) :arrow_down:
lib/module.js 100.00% <100.00%> (ø)
lib/internal/modules/cjs/loader.js 97.59% <90.90%> (-0.06%) :arrow_down:
lib/internal/modules/package_json_reader.js 99.40% <99.08%> (-0.60%) :arrow_down:

... and 34 files with indirect coverage changes

codecov[bot] avatar Oct 16 '24 22:10 codecov[bot]

can you tag it as sh?

That could hack around it, but it would enable shell syntax highlighting. There should be no syntax highlighting.

JakobJingleheimer avatar Oct 17 '24 07:10 JakobJingleheimer

What about text? It's already used in many places of the docs.

targos avatar Oct 17 '24 07:10 targos

What about text? It's already used in many places of the docs.

Huzzah! perfect. I didn't know that was an option. Thanks!

JakobJingleheimer avatar Oct 17 '24 07:10 JakobJingleheimer

CI: https://ci.nodejs.org/job/node-test-pull-request/63167/

nodejs-github-bot avatar Oct 17 '24 21:10 nodejs-github-bot

@aduh95 can we agree to

  1. Correct the misnamed constant.
  2. Land this with the pre-existing and known edge-case …limitation (not sure what to call it since it's the spec'd behaviour) that pjson.exports blocks access to non-exported files.
  3. Break apart your "secret" test-case (it actually contains 4 different cases). I would prefer to do this now, but so much time has been burnt churning on this feature, I have no time left for the next ~month (both in terms of capacity and the impending immovable deadline where I am supposed to present in 2 weeks and still have the actual thing to finish, which is blocked by this feature).
  4. Subsequently try to figure out the quasi-paradox of both respecting and selectively sidestepping node's resolution algorithm.

Leveraging node's resolution is far, far more valuable than accounting for that edge-case. I agree it's desirable to sidestep here.

JakobJingleheimer avatar Oct 18 '24 07:10 JakobJingleheimer

CI: https://ci.nodejs.org/job/node-test-pull-request/63216/

nodejs-github-bot avatar Oct 20 '24 13:10 nodejs-github-bot

What the…

10:03:41 not ok 708 - /home/iojs/build/workspace/node-test-linter/lib/internal/modules/cjs/loader.js
10:03:41   ---
10:03:42   message: '''isUnderNodeModules'' is assigned a value but never used.'

it's used in 3 places

JakobJingleheimer avatar Oct 20 '24 14:10 JakobJingleheimer

I wouldn’t worry about it until the other PR has landed, since this one’s gonna need a rebase anyway

aduh95 avatar Oct 20 '24 14:10 aduh95

CI: https://ci.nodejs.org/job/node-test-pull-request/63254/

nodejs-github-bot avatar Oct 22 '24 19:10 nodejs-github-bot

Related Windows failure:

---
duration_ms: 399.026
exitcode: 1
severity: fail
stack: "\u25B6 findPackageJSON\n  \u2714 should throw when no arguments are provided\
  \ (2.5201ms)\n  \u2714 should throw when parentLocation is invalid (1.177ms)\n \
  \ \u2716 should accept a file URL (string), like from `import.meta.resolve()` (13.1186ms)\n\
  \    AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:\n   \
  \ + actual - expected\n\n    + '\\\\\\\\?\\\\c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\
  \\node\\\\test\\\\fixtures\\\\packages\\\\root-types-field\\\\package.json'\n  \
  \  - 'c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\\node\\\\test\\\\\
  fixtures\\\\packages\\\\root-types-field\\\\package.json'\n\n        at TestContext.<anonymous>\
  \ (c:\\workspace\\node-test-binary-windows-js-suites\\node\\test\\parallel\\test-find-package-json.js:33:12)\n\
  \        at Test.runInAsyncScope (node:async_hooks:211:14)\n        at Test.run\
  \ (node:internal/test_runner/test:934:25)\n        at Suite.processPendingSubtests\
  \ (node:internal/test_runner/test:633:18)\n        at Test.postRun (node:internal/test_runner/test:1045:19)\n\
  \        at Test.run (node:internal/test_runner/test:973:12)\n        at async Suite.processPendingSubtests\
  \ (node:internal/test_runner/test:633:7) {\n      generatedMessage: true,\n    \
  \  code: 'ERR_ASSERTION',\n      actual: '\\\\\\\\?\\\\c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\
  \\node\\\\test\\\\fixtures\\\\packages\\\\root-types-field\\\\package.json',\n \
  \     expected: 'c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\\node\\\
  \\test\\\\fixtures\\\\packages\\\\root-types-field\\\\package.json',\n      operator:\
  \ 'strictEqual'\n    }\n\n  \u2716 should accept a file URL instance (1.1206ms)\n\
  \    AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:\n   \
  \ + actual - expected\n\n    + '\\\\\\\\?\\\\c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\
  \\node\\\\test\\\\fixtures\\\\packages\\\\root-types-field\\\\package.json'\n  \
  \  - 'c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\\node\\\\test\\\\\
  fixtures\\\\packages\\\\root-types-field\\\\package.json'\n\n        at TestContext.<anonymous>\
  \ (c:\\workspace\\node-test-binary-windows-js-suites\\node\\test\\parallel\\test-find-package-json.js:43:12)\n\
  \        at Test.runInAsyncScope (node:async_hooks:211:14)\n        at Test.run\
  \ (node:internal/test_runner/test:934:25)\n        at Suite.processPendingSubtests\
  \ (node:internal/test_runner/test:633:18)\n        at Test.postRun (node:internal/test_runner/test:1045:19)\n\
  \        at Test.run (node:internal/test_runner/test:973:12)\n        at async Suite.processPendingSubtests\
  \ (node:internal/test_runner/test:633:7) {\n      generatedMessage: true,\n    \
  \  code: 'ERR_ASSERTION',\n      actual: '\\\\\\\\?\\\\c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\
  \\node\\\\test\\\\fixtures\\\\packages\\\\root-types-field\\\\package.json',\n \
  \     expected: 'c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\\node\\\
  \\test\\\\fixtures\\\\packages\\\\root-types-field\\\\package.json',\n      operator:\
  \ 'strictEqual'\n    }\n\n  \u2716 should be able to crawl up (CJS) (18.2144ms)\n\
  \    TypeError [ERR_UNSUPPORTED_RESOLVE_REQUEST]: Failed to resolve module specifier\
  \ \"..\" from \"c:\\workspace\\node-test-binary-windows-js-suites\\node\\test\\\
  fixtures\\packages\\nested\\sub-pkg-cjs\\index.js\": Invalid relative URL or base\
  \ scheme is not hierarchical.\n        at moduleResolve (node:internal/modules/esm/resolve:839:21)\n\
  \        at defaultResolve (node:internal/modules/esm/resolve:984:11)\n        ...\
  \ 6 lines matching cause stack trace ...\n        at Object..js (node:internal/modules/cjs/loader:1709:10)\n\
  \        at Module.load (node:internal/modules/cjs/loader:1315:32) {\n      code:\
  \ 'ERR_UNSUPPORTED_RESOLVE_REQUEST',\n      cause: TypeError: Invalid URL\n    \
  \      at new URL (node:internal/url:816:29)\n          at moduleResolve (node:internal/modules/esm/resolve:837:18)\n\
  \          at defaultResolve (node:internal/modules/esm/resolve:984:11)\n      \
  \    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:650:12)\n\
  \          at #cachedDefaultResolve (node:internal/modules/esm/loader:599:25)\n\
  \          at ModuleLoader.resolve (node:internal/modules/esm/loader:582:38)\n \
  \         at findPackageJSON (node:internal/modules/package_json_reader:304:37)\n\
  \          at Object.<anonymous> (c:\\workspace\\node-test-binary-windows-js-suites\\\
  node\\test\\fixtures\\packages\\nested\\sub-pkg-cjs\\index.js:3:18)\n          at\
  \ Module._compile (node:internal/modules/cjs/loader:1572:14)\n          at Object..js\
  \ (node:internal/modules/cjs/loader:1709:10) {\n        code: 'ERR_INVALID_URL',\n\
  \        input: '..',\n        base: 'c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\
  \\node\\\\test\\\\fixtures\\\\packages\\\\nested\\\\sub-pkg-cjs\\\\index.js'\n \
  \     }\n    }\n\n  \u2716 should be able to crawl up (ESM) (32.2874ms)\n    AssertionError\
  \ [ERR_ASSERTION]: Expected values to be strictly equal:\n    + actual - expected\n\
  \n    + '\\\\\\\\?\\\\c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\\\
  node\\\\test\\\\fixtures\\\\packages\\\\nested\\\\package.json'\n    - 'c:\\\\workspace\\\
  \\node-test-binary-windows-js-suites\\\\node\\\\test\\\\fixtures\\\\packages\\\\\
  nested\\\\package.json'\n\n        at TestContext.<anonymous> (c:\\workspace\\node-test-binary-windows-js-suites\\\
  node\\test\\parallel\\test-find-package-json.js:65:12)\n        at Test.runInAsyncScope\
  \ (node:async_hooks:211:14)\n        at Test.run (node:internal/test_runner/test:934:25)\n\
  \        at Suite.processPendingSubtests (node:internal/test_runner/test:633:18)\n\
  \        at Test.postRun (node:internal/test_runner/test:1045:19)\n        at Test.run\
  \ (node:internal/test_runner/test:973:12)\n        at async Suite.processPendingSubtests\
  \ (node:internal/test_runner/test:633:7) {\n      generatedMessage: true,\n    \
  \  code: 'ERR_ASSERTION',\n      actual: '\\\\\\\\?\\\\c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\
  \\node\\\\test\\\\fixtures\\\\packages\\\\nested\\\\package.json',\n      expected:\
  \ 'c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\\node\\\\test\\\\fixtures\\\
  \\packages\\\\nested\\\\package.json',\n      operator: 'strictEqual'\n    }\n\n\
  \  \u2714 can require via package.json (20.7419ms)\n  \u2714 should be able to do\
  \ whatever the heck Antoine created (36.2957ms)\n\u2716 findPackageJSON (127.7596ms)\n\
  501 901 742 483\n\n\u2139 tests 8\n\u2139 suites 1\n\u2139 pass 4\n\u2139 fail 4\n\
  \u2139 cancelled 0\n\u2139 skipped 0\n\u2139 todo 0\n\u2139 duration_ms 228.3553\n\
  \n\u2716 failing tests:\n\ntest at test\\parallel\\test-find-package-json.js:30:3\n\
  \u2716 should accept a file URL (string), like from `import.meta.resolve()` (13.1186ms)\n\
  \  AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:\n  + actual\
  \ - expected\n\n  + '\\\\\\\\?\\\\c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\
  \\node\\\\test\\\\fixtures\\\\packages\\\\root-types-field\\\\package.json'\n  -\
  \ 'c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\\node\\\\test\\\\fixtures\\\
  \\packages\\\\root-types-field\\\\package.json'\n\n      at TestContext.<anonymous>\
  \ (c:\\workspace\\node-test-binary-windows-js-suites\\node\\test\\parallel\\test-find-package-json.js:33:12)\n\
  \      at Test.runInAsyncScope (node:async_hooks:211:14)\n      at Test.run (node:internal/test_runner/test:934:25)\n\
  \      at Suite.processPendingSubtests (node:internal/test_runner/test:633:18)\n\
  \      at Test.postRun (node:internal/test_runner/test:1045:19)\n      at Test.run\
  \ (node:internal/test_runner/test:973:12)\n      at async Suite.processPendingSubtests\
  \ (node:internal/test_runner/test:633:7) {\n    generatedMessage: true,\n    code:\
  \ 'ERR_ASSERTION',\n    actual: '\\\\\\\\?\\\\c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\
  \\node\\\\test\\\\fixtures\\\\packages\\\\root-types-field\\\\package.json',\n \
  \   expected: 'c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\\node\\\\\
  test\\\\fixtures\\\\packages\\\\root-types-field\\\\package.json',\n    operator:\
  \ 'strictEqual'\n  }\n\ntest at test\\parallel\\test-find-package-json.js:39:3\n\
  \u2716 should accept a file URL instance (1.1206ms)\n  AssertionError [ERR_ASSERTION]:\
  \ Expected values to be strictly equal:\n  + actual - expected\n\n  + '\\\\\\\\\
  ?\\\\c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\\node\\\\test\\\\fixtures\\\
  \\packages\\\\root-types-field\\\\package.json'\n  - 'c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\
  \\node\\\\test\\\\fixtures\\\\packages\\\\root-types-field\\\\package.json'\n\n\
  \      at TestContext.<anonymous> (c:\\workspace\\node-test-binary-windows-js-suites\\\
  node\\test\\parallel\\test-find-package-json.js:43:12)\n      at Test.runInAsyncScope\
  \ (node:async_hooks:211:14)\n      at Test.run (node:internal/test_runner/test:934:25)\n\
  \      at Suite.processPendingSubtests (node:internal/test_runner/test:633:18)\n\
  \      at Test.postRun (node:internal/test_runner/test:1045:19)\n      at Test.run\
  \ (node:internal/test_runner/test:973:12)\n      at async Suite.processPendingSubtests\
  \ (node:internal/test_runner/test:633:7) {\n    generatedMessage: true,\n    code:\
  \ 'ERR_ASSERTION',\n    actual: '\\\\\\\\?\\\\c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\
  \\node\\\\test\\\\fixtures\\\\packages\\\\root-types-field\\\\package.json',\n \
  \   expected: 'c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\\node\\\\\
  test\\\\fixtures\\\\packages\\\\root-types-field\\\\package.json',\n    operator:\
  \ 'strictEqual'\n  }\n\ntest at test\\parallel\\test-find-package-json.js:52:3\n\
  \u2716 should be able to crawl up (CJS) (18.2144ms)\n  TypeError [ERR_UNSUPPORTED_RESOLVE_REQUEST]:\
  \ Failed to resolve module specifier \"..\" from \"c:\\workspace\\node-test-binary-windows-js-suites\\\
  node\\test\\fixtures\\packages\\nested\\sub-pkg-cjs\\index.js\": Invalid relative\
  \ URL or base scheme is not hierarchical.\n      at moduleResolve (node:internal/modules/esm/resolve:839:21)\n\
  \      at defaultResolve (node:internal/modules/esm/resolve:984:11)\n      ... 6\
  \ lines matching cause stack trace ...\n      at Object..js (node:internal/modules/cjs/loader:1709:10)\n\
  \      at Module.load (node:internal/modules/cjs/loader:1315:32) {\n    code: 'ERR_UNSUPPORTED_RESOLVE_REQUEST',\n\
  \    cause: TypeError: Invalid URL\n        at new URL (node:internal/url:816:29)\n\
  \        at moduleResolve (node:internal/modules/esm/resolve:837:18)\n        at\
  \ defaultResolve (node:internal/modules/esm/resolve:984:11)\n        at ModuleLoader.defaultResolve\
  \ (node:internal/modules/esm/loader:650:12)\n        at #cachedDefaultResolve (node:internal/modules/esm/loader:599:25)\n\
  \        at ModuleLoader.resolve (node:internal/modules/esm/loader:582:38)\n   \
  \     at findPackageJSON (node:internal/modules/package_json_reader:304:37)\n  \
  \      at Object.<anonymous> (c:\\workspace\\node-test-binary-windows-js-suites\\\
  node\\test\\fixtures\\packages\\nested\\sub-pkg-cjs\\index.js:3:18)\n        at\
  \ Module._compile (node:internal/modules/cjs/loader:1572:14)\n        at Object..js\
  \ (node:internal/modules/cjs/loader:1709:10) {\n      code: 'ERR_INVALID_URL',\n\
  \      input: '..',\n      base: 'c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\
  \\node\\\\test\\\\fixtures\\\\packages\\\\nested\\\\sub-pkg-cjs\\\\index.js'\n \
  \   }\n  }\n\ntest at test\\parallel\\test-find-package-json.js:60:3\n\u2716 should\
  \ be able to crawl up (ESM) (32.2874ms)\n  AssertionError [ERR_ASSERTION]: Expected\
  \ values to be strictly equal:\n  + actual - expected\n\n  + '\\\\\\\\?\\\\c:\\\\\
  workspace\\\\node-test-binary-windows-js-suites\\\\node\\\\test\\\\fixtures\\\\\
  packages\\\\nested\\\\package.json'\n  - 'c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\
  \\node\\\\test\\\\fixtures\\\\packages\\\\nested\\\\package.json'\n\n      at TestContext.<anonymous>\
  \ (c:\\workspace\\node-test-binary-windows-js-suites\\node\\test\\parallel\\test-find-package-json.js:65:12)\n\
  \      at Test.runInAsyncScope (node:async_hooks:211:14)\n      at Test.run (node:internal/test_runner/test:934:25)\n\
  \      at Suite.processPendingSubtests (node:internal/test_runner/test:633:18)\n\
  \      at Test.postRun (node:internal/test_runner/test:1045:19)\n      at Test.run\
  \ (node:internal/test_runner/test:973:12)\n      at async Suite.processPendingSubtests\
  \ (node:internal/test_runner/test:633:7) {\n    generatedMessage: true,\n    code:\
  \ 'ERR_ASSERTION',\n    actual: '\\\\\\\\?\\\\c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\
  \\node\\\\test\\\\fixtures\\\\packages\\\\nested\\\\package.json',\n    expected:\
  \ 'c:\\\\workspace\\\\node-test-binary-windows-js-suites\\\\node\\\\test\\\\fixtures\\\
  \\packages\\\\nested\\\\package.json',\n    operator: 'strictEqual'\n  }\n(node:5568)\
  \ ExperimentalWarning: CommonJS module c:\\workspace\\node-test-binary-windows-js-suites\\\
  node\\test\\parallel\\test-find-package-json.js is loading ES Module c:\\workspace\\\
  node-test-binary-windows-js-suites\\node\\test\\fixtures\\packages\\nested\\sub-pkg-esm\\\
  index.js using require().\nSupport for loading ES Module in require() is an experimental\
  \ feature and might change at any time\n(Use `node --trace-warnings ...` to show\
  \ where the warning was created)"

aduh95 avatar Oct 22 '24 20:10 aduh95

Note that https://github.com/nodejs/node/pull/55412/commits/d31712c85c6054d0a0106018e0393c1fa0da2eaa is not Windows-related, it's just nits to improve the readability

aduh95 avatar Oct 22 '24 20:10 aduh95

CI: https://ci.nodejs.org/job/node-test-pull-request/63259/

nodejs-github-bot avatar Oct 22 '24 21:10 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/63262/

nodejs-github-bot avatar Oct 23 '24 09:10 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/63261/

nodejs-github-bot avatar Oct 23 '24 09:10 nodejs-github-bot

@JakobJingleheimer rekicking CI won't help until the Windows failures have been taken care of

aduh95 avatar Oct 23 '24 09:10 aduh95

Ahh, I was finally able to track down where the error is actually exposed

not ok 288 parallel/test-find-package-json
      ✖ should accept a file URL (string), like from `import.meta.resolve()` (17.804ms)
      AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

        + actual - expected
        
        + '\\\\?\\d:\\workspace\\node-test-binary-windows-js-suites\\node\\test\\fixtures\\packages\\root-types-field\\package.json'
        - 'd:\\workspace\\node-test-binary-windows-js-suites\\node\\test\\fixtures\\packages\\root-types-field\\package.json'

which is coming from

assert.strictEqual(
  findPackageJSON(`${specifierBase}index.js`, importMetaUrl),
  fixtures.path(specifierBase, 'package.json'),
);

On mac, fixtures.path() outputs a path, but on windows it’s outputting a file URL. Is this known behaviour?

Under the hood, it's using path.join(__dirname, …)

JakobJingleheimer avatar Oct 23 '24 13:10 JakobJingleheimer

on windows it’s outputting a file URL

It looks nothing like a file: URL, file: URL starts with file:// which clearly does not match \\?\d:\workspace\…. That looks more like a UNC path, which is why I suggested wrapping with path.toNamespacedPath in https://github.com/nodejs/node/pull/55412#discussion_r1811394981

aduh95 avatar Oct 23 '24 14:10 aduh95

CI: https://ci.nodejs.org/job/node-test-pull-request/63264/

nodejs-github-bot avatar Oct 23 '24 17:10 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/63265/

nodejs-github-bot avatar Oct 23 '24 17:10 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/63266/

nodejs-github-bot avatar Oct 23 '24 17:10 nodejs-github-bot

There are still 2 related Windows failures:

      ✖ should be able to crawl up (CJS) (16.4776ms)
        TypeError [ERR_UNSUPPORTED_RESOLVE_REQUEST]: Failed to resolve module specifier ".." from "c:\workspace\node-test-binary-windows-js-suites\node\test\fixtures\packages\nested\sub-pkg-cjs\index.js": Invalid relative URL or base scheme is not hierarchical.
            at moduleResolve (node:internal/modules/esm/resolve:839:21)
            at defaultResolve (node:internal/modules/esm/resolve:984:11)
            ... 6 lines matching cause stack trace ...
            at Object..js (node:internal/modules/cjs/loader:1709:10)
            at Module.load (node:internal/modules/cjs/loader:1315:32) {
          code: 'ERR_UNSUPPORTED_RESOLVE_REQUEST',
          cause: TypeError: Invalid URL
              at new URL (node:internal/url:816:29)
              at moduleResolve (node:internal/modules/esm/resolve:837:18)
              at defaultResolve (node:internal/modules/esm/resolve:984:11)
              at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:650:12)
              at #cachedDefaultResolve (node:internal/modules/esm/loader:599:25)
              at ModuleLoader.resolve (node:internal/modules/esm/loader:582:38)
              at findPackageJSON (node:internal/modules/package_json_reader:304:37)
              at Object.<anonymous> (c:\workspace\node-test-binary-windows-js-suites\node\test\fixtures\packages\nested\sub-pkg-cjs\index.js:3:18)
              at Module._compile (node:internal/modules/cjs/loader:1572:14)
              at Object..js (node:internal/modules/cjs/loader:1709:10) {
            code: 'ERR_INVALID_URL',
            input: '..',
            base: 'c:\\workspace\\node-test-binary-windows-js-suites\\node\\test\\fixtures\\packages\\nested\\sub-pkg-cjs\\index.js'
          }
        }
    
      ✖ should be able to crawl up (ESM) (27.3107ms)
        AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
        + actual - expected
        
        + '\\\\?\\c:\\workspace\\node-test-binary-windows-js-suites\\node\\test\\fixtures\\packages\\nested\\package.json'
        - 'c:\\workspace\\node-test-binary-windows-js-suites\\node\\test\\fixtures\\packages\\nested\\package.json'
        
            at TestContext.<anonymous> (c:\workspace\node-test-binary-windows-js-suites\node\test\parallel\test-find-package-json.js:64:12)
            at Test.runInAsyncScope (node:async_hooks:211:14)
            at Test.run (node:internal/test_runner/test:934:25)
            at Suite.processPendingSubtests (node:internal/test_runner/test:633:18)
            at Test.postRun (node:internal/test_runner/test:1045:19)
            at Test.run (node:internal/test_runner/test:973:12)
            at async Suite.processPendingSubtests (node:internal/test_runner/test:633:7) {
          generatedMessage: true,
          code: 'ERR_ASSERTION',
          actual: '\\\\?\\c:\\workspace\\node-test-binary-windows-js-suites\\node\\test\\fixtures\\packages\\nested\\package.json',
          expected: 'c:\\workspace\\node-test-binary-windows-js-suites\\node\\test\\fixtures\\packages\\nested\\package.json',
          operator: 'strictEqual'
        }
    

aduh95 avatar Oct 23 '24 20:10 aduh95

There are still 2 related Windows failures

Thanks, I saw. I missed them before when looking in the asserts.

JakobJingleheimer avatar Oct 23 '24 21:10 JakobJingleheimer