Repository navigation
Fix nodejs.install with npm 12 - #7031
cristianchiriac wants to merge 1 commit into
Conversation
npm 12 rejects unknown CLI flags, and --platform/--arch are legacy aliases it no longer knows, so the install of nodejs.install packages failed with EUNKNOWNCONFIG. Use only --os/--cpu (npm 9.9+). Fixes anomalyco#6946
|
@cristianchiriac, your change is in the community fork: sst-community/sst#122, released in v4.21.3 (tracked in sst-community/sst#121). Your commit and authorship are kept, with no changes on top. I checked it on npm 10.9.2, 11.12.1 and 12.2.0. In an empty project the old arguments fail on npm 12 with I also deployed to AWS three functions that use npm older than 9.9 doesn't select the target architecture with The community fork accepts pull requests, so you are welcome to send them there as well. |
Fixes #6946
npm 12 throws on unknown CLI flags instead of warning (npm/cli#9276). The
npm installthatnodejs.installruns for a function passed--platform=linuxand--arch=x64|arm64, legacy aliases npm no longer knows, so builds fail with:The install now passes only
--os=linuxand--cpu=<x64|arm64>, plus--libc=glibcforsharpas before. Those have selected the target platform since npm 9.9 (npm/cli#6776), so npm 10/11 behave the same. The argument list moved into a smallnpmInstallArgs(architecture, packages), which also replaces the arm64 patching by slice index (cmd[4],cmd[5]). That patching would have shifted onto the wrong flags once two entries were removed.Tests:
TestNpmInstallArgsinpkg/runtime/node/build_test.go: x86_64, arm64, and arm64 withsharp. It also checks that no--platform/--archflag is left.go test ./pkg/runtime/node/andgo vetpass. gofmt is clean.npx npm@12.2.0 install --force --platform=linux --os=linux --arch=x64 --cpu=x64fails withEUNKNOWNCONFIG.npx npm@12.2.0 install --force --os=linux --cpu=x64installs.--cpu=arm64.I didn't run a full
sst deploy.