← Back to issue list

nodejs plugin assumes a version key in the package.json

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1838474
Type
issue
State
open
Author
~robcresswell-deactivatedaccount
Labels
—
Created
Updated
Closed
—

Current evaluation

Legacy nodejs plugin crashed when package.json omitted its optional version field; active Snapcraft now uses the npm plugin and no longer contains that implementation.

Suggested action: close stale

Reason: Commit 38996d538 (#2984) moved the legacy nodejs plugin out of Snapcraft, and the current tree has no snapcraft/plugins/nodejs.py. Migration documentation explicitly replaces nodejs with npm, whose current implementation packs package.json without reading a version field, so the affected implementation is obsolete.

Evaluated by: mr-cal-bot

Impact: 20 Quick Win: 3 Complexity: 10 Confidence: 95 Actionability: 15

Issue body

The nodejs plugin currently assumes a version key is present in the package.json[1]; crashing out with a KeyError if it isn't, and doesn't enable any other way of providing a package version, nor does it appear to inherit or otherwise use the 'version' key in the snapcraft.yaml. What's the best way to fix this? I've really lost my patience trying to wrestle with the tooling and broken links in the documentation, so I'd like to raise a PR to address this ASAP so I can move on. 1. https://github.com/snapcore/snapcraft/blob/master/snapcraft/plugins/nodejs.py#L211

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 20
Quick Win: 3
Complexity: 10
Confidence: 95
Actionability: 15
close stale Legacy nodejs plugin crashed when package.json omitted its optional version field; active Snapcraft now uses the npm plugin and no longer contains that implementation.
stealth/space-bunny-alpha
Impact: 12
Quick Win: 4
Complexity: 25
Confidence: 84
Actionability: 40
close stale Legacy snapcraft nodejs plugin raised KeyError when package.json had no version key and offered no override. That plugin no longer exists; the npm plugin in craft-parts takes the version via adopt-info/override-build instead.
stealth/space-bunny-alpha
Impact: 0
Quick Win: 0
Complexity: 0
Confidence: 97
Actionability: 0
close stale Legacy nodejs plugin’s package.json version lookup is obsolete: Snapcraft replaced nodejs with npm, and the current npm implementation does not read package.json versions.
qwen/qwen3.8-27b
Impact: 20
Quick Win: 12
Staleness: 95
Complexity: 40
Confidence: 75
Support Request: 10
close stale Nodejs plugin crashed with KeyError when package.json lacked a version key, with no fallback to snapcraft.yaml version. Reported 2019, zero comments, no maintainer response. The nodejs plugin has since been removed and replaced by the npm plugin, so the referenced code no longer exists.
qwen/qwen3.6-35b-a3b
Staleness: 98
Complexity: 15
Confidence: 90
Support Request: 5
close stale Nodejs plugin crashes with KeyError when package.json lacks a version key. Untriaged, inactive for ~7 years, no maintainer response.
qwen/qwen3.6-35b-a3b
Staleness: 98
Complexity: 25
Confidence: 85
Support Request: 5
close stale Nodejs plugin crashes with KeyError when package.json lacks a version key. Unlabeled, no maintainer response, inactive for over 7 years.
qwen3.6-35b-a3b-mtp-q6
Staleness: 98
Complexity: 25
Confidence: 90
Support Request: 10
close stale Nodejs plugin crashes with KeyError when package.json lacks a version key. Open for ~7 years with no maintainer response or labels.

Update history

Date Change
created

Related work

  • Related To: snapcraft#2984 (confidence 95%)

    Commit 38996d538 moved the existing plugins to a separate package; current Snapcraft documentation uses npm instead of nodejs.

Related issues

Issue Project State Summary Similarity
#2424 nodejs plugin: fail gracefully when a package.json is missing snapcraft merged Merged in canonical/snapcraft#2424 as 99b7cc984, making the Node.js plugin fail gracefully when package.json is missing; resolves LP #1807971.
73%
#1586104 nodejs plugin: Unable to use node version other than 4.2.2 snapcraft (launchpad) closed nodejs plugin's hard-coded node 4.2.2 made configurable via a new `node-engine` key; implemented in snapcraft PR #509 (commit d579b556e), released in snapcraft 2.10 and verified in xenial-proposed.
72%
#1632553 In the nodejs plugin, there is no way to specify the npm version required snapcraft (launchpad) closed A dedicated npm plugin now supports selecting npm versions, resolving the legacy Node.js plugin limitation via craft-parts#200 (commit b9881154).
72%
#1886858 nodejs plugin doesn't set npm path for custom node version snapcraft (launchpad) open Legacy nodejs builds could miss downloaded npm on PATH; current Snapcraft has replaced nodejs with npm and removed core18 support, leaving this old report obsolete.
71%
#1955887 snapcraft npm doesn't respect npm-node-version snapcraft (launchpad) open Legacy npm configuration was misleading: override-build bypasses the plugin-managed Node download; current craft-parts requires npm-include-node with npm-node-version.
70%