How to use npm with asdf and Nodejs v11 - I get segmentation faults

1.2k Views Asked by At

For a new project on my Ubuntu 22.04.3 LTS, I had to make the switch from nvm to asdf.

I ran

nvm deactivate
nvm uninstall 20
nvm uninstall ...[all locally available node versions]
npm unload

then installed NodeJS using

asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
asdf install node latest
asdf global nodejs latest
asdf local nodejs latest

It works fine and I have the right npm version at hand for almost all NodeJS versions used in different projects.

Bare one: For one very old project, I still need to use nodejs v11.1.0. So I ran asdf install nodejs 11.1.0 and now asdf switches to that version whenever I get into that project's directory - respecting my old .nvmrc file thanks to the egacy_version_file = yes setting in my ~/.asdfrc file.

But when I want to use npm, it always results in a segmentation fault (core dumped) npm.

Before asdf, when I used nvm with nvm use and the proper .nvmrc file in that project's directory, nvm switched to npm v6.4.1 and everything worked just fine. Now with asdf, I always get that segmentation fault for npm, no matter which 11.x version of NodeJS I rtry to install with asdf.

which npm yields /home/USER/.asdf/shims/npm

and cat /home/USER/.asdf/shims/npm brings me

#!/usr/bin/env bash
# asdf-plugin: nodejs 20.6.1
# asdf-plugin: nodejs 18.17.1
# asdf-plugin: nodejs 11.1.0
# asdf-plugin: nodejs 11.0.0
# asdf-plugin: nodejs 11.15.0
exec /home/USER/.asdf/bin/asdf exec "npm" "$@"

but this doesn't really tell me anything.

I have no idea what's going on there. If anyone could provide me with a hint on how to get a working npm v6.4.1 running with asdf and NodeJS v11.1.0, that would be of great help.

I tried to install that needed npm version using npm i -g [email protected] while in another project, as I thought maybe it has to be installed once in that version, but now asdf automatically switches to that version of npm whenever I am in this other project's directory, and I can't undo it, as now every time I try to run npm i -g [email protected], I get the error that npm does not support Node.js v18.17.1, which is the NodeJS version used in that project. So the situation got even worse.

Also, I did not find any relevant article googling for asdf and npm and segmentation fault.

0

There are 0 best solutions below