canonical / craft-parts

https://canonical-craft-parts.readthedocs-hosted.com
GNU Lesser General Public License v3.0
11 stars 38 forks source link

NPM Plugin: wrong node version is used to build the package #770

Open dimaqq opened 4 months ago

dimaqq commented 4 months ago

Bug Description

Looks like npm-node-version is not honoured. I've requested 20.15, but debug shows that 12.22.9 is actually used

To Reproduce

Observe that node version is v12.22.9 despite the requested latest or 20.15 or seemingly any.

part yaml

traefik-frontend:
    plugin: npm
    source-type: git
    source-depth: 1
    source-tag: "v2.11.3"
    source: https://github.com/traefik/traefik
    npm-include-node: true
    npm-node-version: "node"
    build-packages:
      - nodejs
      - npm
    override-build: |
      npm install -g yarn && \
      cd ./webui && \
      # added --legacy-peer-deps to avoid dependency resolution errors with mocha (testing)
      npm install --legacy-peer-deps && \
      # Build the bundle as per:
      # https://github.com/traefik/traefik/blob/84a081054688349fa4e2513599e3bf2395331492/Makefile#L66
      npm run build:nc && \
      # cleanup
      rm -rf node_modules

Relevant log output

...

2024-07-03 21:21:44.567 :: 2024-07-03 21:19:13.222 :: Get:15 http://ports.ubuntu.com/ubuntu-ports jammy-updates/universe arm64 libnode72 arm64 12.22.9~dfsg-1ubuntu3.6 [10.3 MB]
2024-07-03 21:21:44.567 :: 2024-07-03 21:19:14.202 :: Get:16 http://ports.ubuntu.com/ubuntu-ports jammy-updates/universe arm64 libnode-dev arm64 12.22.9~dfsg-1ubuntu3.6 [609 kB]
2024-07-03 21:21:44.567 :: 2024-07-03 21:19:14.245 :: Get:17 http://ports.ubuntu.com/ubuntu-ports jammy-updates/universe arm64 nodejs arm64 12.22.9~dfsg-1ubuntu3.6 [122 kB]

...

2024-07-03 21:21:44.574 :: 2024-07-03 21:21:37.268 :: npm WARN EBADENGINE Unsupported engine {
2024-07-03 21:21:44.574 :: 2024-07-03 21:21:37.268 :: npm WARN EBADENGINE   package: 'traefik-ui@2.0.0',
2024-07-03 21:21:44.574 :: 2024-07-03 21:21:37.268 :: npm WARN EBADENGINE   required: { node: '^20 || ^18 || ^16', npm: '>= 6.13.4', yarn: '>= 1.21.1' },
2024-07-03 21:21:44.574 :: 2024-07-03 21:21:37.268 :: npm WARN EBADENGINE   current: { node: 'v12.22.9', npm: '8.5.1' }
2024-07-03 21:21:44.574 :: 2024-07-03 21:21:37.268 :: npm WARN EBADENGINE }

...

2024-07-03 21:21:44.575 :: 2024-07-03 21:21:44.101 :: error traefik-ui@2.0.0: The engine "node" is incompatible with this module. Expected version "^20 || ^18 || ^16". Got "12.22.9"

Links:
https://github.com/canonical/traefik-rock/pull/35
https://matrix.to/#/!NPPCseDHKRvSBMUEXN:ubuntu.com/$oeD-GjAt-I3Yv8faXHn9OBVSmN5udLkB_Y4CKsBrslY?via=ubuntu.com&via=matrix.org
dimaqq commented 4 months ago

Full log

rockcraft-20240703-211735.010795.log

dimaqq commented 4 months ago

At the very least, if the requested nodejs version cannot be installed (e.g. the base is too old), it would be much better to give an error instead.

Ideally, custom node should be used, because, well, 12.x is really old.

syncronize-issues-to-jira[bot] commented 4 months ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3124.

This message was autogenerated