asdf-nodejs icon indicating copy to clipboard operation
asdf-nodejs copied to clipboard

NPM fails to run with ASDF v0.17.0 – "Cannot find module 'npm-prefix.js'"

Open pedrorcruzz opened this issue 6 months ago • 2 comments

After upgrading ASDF to version 0.17.0 using Brew, npm stopped working entirely — even though node is correctly installed and recognized. This issue did not occur before the upgrade, and everything works fine when switching to nvm.

The error I get when trying to run npm is:


node:internal/modules/cjs/loader:1408
  throw err;
  ^

Error: Cannot find module '/Users/phrosa/.asdf/installs/nodejs/24.1.0/bin/node_modules/npm/bin/npm-prefix.js'
    ...
Node.js v24.1.0
Could not determine Node.js install directory

I have already tried: • asdf reshim • Reinstalling the Node.js plugin • Switching Node.js versions

Paths differ, and npm cannot find its core files (npm-prefix.js). When I use nvm, everything works perfectly.

pedrorcruzz avatar May 25 '25 01:05 pedrorcruzz

Similar issue, except calling npm for me just hangs. Reverting to asdf 0.16.7 via brew did the trick.

# Based on https://stackoverflow.com/a/79121710/724068
brew uninstall asdf
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/1d665566d3b4d3a493667c45c8fdc68add50cd05/Formula/a/asdf.rb
brew install ./asdf.rb

nickcaballero avatar Jun 03 '25 19:06 nickcaballero

Check if this is fixed on the last version now, #426 should've solved it

augustobmoura avatar Jun 18 '25 13:06 augustobmoura