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

Supported node and npm versions #3577

Open
thoughtsunificator opened this issue Dec 7, 2024 · 15 comments
Open

Supported node and npm versions #3577

thoughtsunificator opened this issue Dec 7, 2024 · 15 comments

Comments

@thoughtsunificator
Copy link

thoughtsunificator commented Dec 7, 2024

Operating system

Linux

Eleventy

npm test

Describe the bug

Test are failing on multiple versions of Node.js (18 and onward) using Eleventy 3.0.0

Running npm test fails for various reasons:

  • import { register } from "node:module

Which is only available since Node.js 20

  • DirContainsTest › Compare to parent dir
    Fails on all versions of Node.js

I tested using both my machine (Node v23.1.0 and npm 10.9.1) and the Docker images: node:19-alpine to node:23-alpine.

I suggest we clarify which versions of Node are supported in the package.json file, currently it only says "Node.js v18 onward" which is obviously not the case. We could also add the supported npm version (which is not the same).

Strangely enough, the CIs all pass?

Reproduction steps

  • Clone 43919d9
  • Run docker run -u $(id -u $USER):$(id -g $USER) -it -v './:/app' -w /app node:23-alpine sh -c 'npm ci && npm test'

Expected behavior

Tests should pass

Reproduction URL

No response

Screenshots

No response

@thoughtsunificator
Copy link
Author

Some dependencies already state their requirements:

  • espree "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
  • ava "node": "^18.18 || ^20.8 || ^22 || >=23"

@Ryuno-Ki
Copy link
Contributor

Ryuno-Ki commented Dec 9, 2024

I'm surprised that the CI doesn't report failing tests.

I can see warnings like

ubuntu-latest pipelines will use ubuntu-24.04 soon. For more details, see actions/runner-images#10636

on https://github.com/11ty/eleventy/actions/runs/12206669545 for example. (Associated with #3573 )

Looking at Release schedule version 18 of Node is still in Maintenance mode. So it could be an indicator to still use it.

Currently, Eleventy's minimum version of Node is >= 18.

I'd like to see a failing test case before moving forward.

@thoughtsunificator
Copy link
Author

thoughtsunificator commented Dec 10, 2024

@Ryuno-Ki Did you manage to have the test pass on your setup though?

@Ryuno-Ki
Copy link
Contributor

On commit d7434ab npm test yields

1296 tests passed
19 tests skipped

here.

(Running Node v20.18.1 via Debian).

Let me grab nvm.

@Ryuno-Ki
Copy link
Contributor

Same results with Node v18.20.5.

@zachleat
Copy link
Member

Please note that there is a distinction between the Node versions that Eleventy supports and the Node versions supported by our devDependencies—they can be different (though that’s not ideal).

espree is used by eslint, for example—not a strict requirement for Eleventy.

@zachleat
Copy link
Member

zachleat commented Dec 10, 2024

I would also note that module.register is an optional progressive enhancement for Node 18.19+ and we feature test for it:

// ESM Cache Buster is an enhancement that works in Node 18.19+

@zachleat
Copy link
Member

Test failure on Node 23 is currently filed at #3518

@thoughtsunificator
Copy link
Author

thoughtsunificator commented Dec 10, 2024

When running docker run -u $(id -u $USER):$(id -g $USER) -it -v './:/app' -w /app node:19-alpine sh -c 'npm ci && npm test', even with the said check it's still failing:

Screenshot

image

Maybe I'm wrong, but it looks like the culprits are:

import "./MdxTest.js";

import { register } from "node:module";

And when running the version above, docker run -u $(id -u $USER):$(id -g $USER) -it -v './:/app' -w /app node:20-alpine sh -c 'npm ci && npm test':

Screenshot

image

The test DirContainsTest › Compare to parent dir always fails. I cannot pass this test no matter what version of Node.js I test against, 18, 19, 20, 21, 22, 23...

Please note that there is a distinction between the Node versions that Eleventy supports and the Node versions supported by our devDependencies—they can be different (though that’s not ideal).

espree is used by eslint, for example—not a strict requirement for Eleventy.

Some are not in the devDependencies, for example, path-scurry which is required by fast-glob if I'm not mistaken has the following requirements: "node": "20 || >=22"

And if I unset --fail-fast I notice that even more tests are failing. The reason is that they are assuming the system has git installed.

Same results with Node v18.20.5.

How abut 19.9.0?

@zachleat
Copy link
Member

I’m confused where you’re getting this info, here’s the current dep graph showing the use of path-scurry:

image

https://npmgraph.js.org/?q=%4011ty%2Feleventy#select=exact%3Apath-scurry%401.11.1

v1.11.1 of path-scurry node support ">=16 || 14 >=14.18" via https://github.com/isaacs/path-scurry/blob/766c9b06aacef86b43c9999cabc5eb824b5958d6/package.json#L67-L69

Happy to look at any other examples you find though!

@thoughtsunificator
Copy link
Author

thoughtsunificator commented Dec 10, 2024

Yep, there are multiple versions of path-scurry, and the one rimraf is using is:

image

I'm getting this info by running npm ci btw.

@zachleat
Copy link
Member

Ah, that explains some confusion. There are two versions of rimraf here: v6.0.1 is via devDependency and v5.0.10 is version used by @11ty/recursive-copy (a first-party dependency)

@zachleat
Copy link
Member

One more thing here, we typically avoid putting resources into debugging odd versions of Node and typically recommend folks use an even number (where possible): https://nodejs.org/en/about/previous-releases

If you feel this policy should be changed, please let me know!

@zachleat
Copy link
Member

I made a change to MdxTest.js to feature test for module.register in the test file per your callout above.

@thoughtsunificator
Copy link
Author

KO on node v19.9.0 (linux) :

> @11ty/[email protected] test:node
> node --test test_node/tests.js

ℹ [11ty] Problem writing Eleventy templates:
ℹ [11ty] 1. There was a problem importing 'test/stubs-fancyjs/test.11ty.tsx' via import(esm) (via EleventyImportError)
ℹ [11ty] 2. Unknown file extension ".tsx" for /app/test/stubs-fancyjs/test.11ty.tsx (via TypeError)
ℹ [11ty] 
ℹ [11ty] Original error stack trace: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".tsx" for /app/test/stubs-fancyjs/test.11ty.tsx
ℹ [11ty]     at new NodeError (node:internal/errors:399:5)
ℹ [11ty]     at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:99:9)
ℹ [11ty]     at defaultGetFormat (node:internal/modules/esm/get_format:139:38)
ℹ [11ty]     at defaultLoad (node:internal/modules/esm/load:83:20)
ℹ [11ty]     at nextLoad (node:internal/modules/esm/hooks:654:28)
ℹ [11ty]     at Hooks.load (node:internal/modules/esm/hooks:445:26)
ℹ [11ty]     at ESMLoader.load (node:internal/modules/esm/loader:337:38)
ℹ [11ty]     at ESMLoader.moduleProvider (node:internal/modules/esm/loader:207:22)
ℹ [11ty]     at new ModuleJob (node:internal/modules/esm/module_job:63:26)
ℹ [11ty]     at #createModuleJob (node:internal/modules/esm/loader:231:17)
✖ Eleventy with JSX (36.955743ms)
  EleventyImportError: "There was a problem importing 'test/stubs-fancyjs/test.11ty.tsx' via import(esm)"
      at file:///app/src/Util/Require.js:192:5
      at async 
      at async 
      at async 
      at async 
      at async TemplateMap.add (file:///app/src/TemplateMap.js:68:14)
      at async Promise.all (index 0)
      at async TemplateWriter._addToTemplateMap (file:///app/src/TemplateWriter.js:342:14)
      at async TemplateWriter._createTemplateMap (file:///app/src/TemplateWriter.js:357:3)
      at async TemplateWriter.generateTemplates (file:///app/src/TemplateWriter.js:389:3)

✔ Eleventy no formats (8.68532ms)
ℹ [11ty] Problem writing Eleventy templates:
ℹ [11ty] 1. There was a problem importing 'test/stubs-fancyjs/test.11ty.tsx' via import(esm) (via EleventyImportError)
ℹ [11ty] 2. Unknown file extension ".tsx" for /app/test/stubs-fancyjs/test.11ty.tsx (via TypeError)
ℹ [11ty] 
ℹ [11ty] Original error stack trace: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".tsx" for /app/test/stubs-fancyjs/test.11ty.tsx
ℹ [11ty]     at new NodeError (node:internal/errors:399:5)
ℹ [11ty]     at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:99:9)
ℹ [11ty]     at defaultGetFormat (node:internal/modules/esm/get_format:139:38)
ℹ [11ty]     at defaultLoad (node:internal/modules/esm/load:83:20)
ℹ [11ty]     at nextLoad (node:internal/modules/esm/hooks:654:28)
ℹ [11ty]     at Hooks.load (node:internal/modules/esm/hooks:445:26)
ℹ [11ty]     at ESMLoader.load (node:internal/modules/esm/loader:337:38)
ℹ [11ty]     at ESMLoader.moduleProvider (node:internal/modules/esm/loader:207:22)
ℹ [11ty]     at new ModuleJob (node:internal/modules/esm/module_job:63:26)
ℹ [11ty]     at #createModuleJob (node:internal/modules/esm/loader:231:17)
✖ Eleventy JSX --formats=11ty.tsx (7.611089ms)
  EleventyImportError: "There was a problem importing 'test/stubs-fancyjs/test.11ty.tsx' via import(esm)"
      at file:///app/src/Util/Require.js:192:5

✔ Eleventy JSX --formats=tsx (3.73946ms)
✖ Eleventy with MDX (4.420456ms)
  EleventyImportError: "There was a problem importing 'test/stubs-fancyjs/test.mdx' via import(esm)"
      at file:///app/src/Util/Require.js:192:5
      at async 
      at async 
      at async 
      at async 
      at async TemplateMap.add (file:///app/src/TemplateMap.js:68:14)
      at async Promise.all (index 0)
      at async TemplateWriter._addToTemplateMap (file:///app/src/TemplateWriter.js:342:14)
      at async TemplateWriter._createTemplateMap (file:///app/src/TemplateWriter.js:357:3)
      at async TemplateWriter.generateTemplates (file:///app/src/TemplateWriter.js:389:3)

ℹ tests 5
ℹ suites 0
ℹ pass 2
ℹ fail 3
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 416.955984

✖ failing tests:

✖ Eleventy with JSX (36.955743ms)
  EleventyImportError: "There was a problem importing 'test/stubs-fancyjs/test.11ty.tsx' via import(esm)"
      at file:///app/src/Util/Require.js:192:5
      at async 
      at async 
      at async 
      at async 
      at async TemplateMap.add (file:///app/src/TemplateMap.js:68:14)
      at async Promise.all (index 0)
      at async TemplateWriter._addToTemplateMap (file:///app/src/TemplateWriter.js:342:14)
      at async TemplateWriter._createTemplateMap (file:///app/src/TemplateWriter.js:357:3)
      at async TemplateWriter.generateTemplates (file:///app/src/TemplateWriter.js:389:3)

✖ Eleventy JSX --formats=11ty.tsx (7.611089ms)
  EleventyImportError: "There was a problem importing 'test/stubs-fancyjs/test.11ty.tsx' via import(esm)"
      at file:///app/src/Util/Require.js:192:5

✖ Eleventy with MDX (4.420456ms)
  EleventyImportError: "There was a problem importing 'test/stubs-fancyjs/test.mdx' via import(esm)"
      at file:///app/src/Util/Require.js:192:5
      at async 
      at async 
      at async 
      at async 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants