tj / n

Node version management

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installing v12.22.12 does not install the correct npm version

mkusold opened this issue · comments

Bug Report

Summary

Node documentation says that node 12.22.12 corresponds with npm version 6.14.16; however, when I install 12.22.12, my npm version is not 6.14.16.
image

Steps to Reproduce

kusold@Milos-MBP web % n 
     copying : node/16.13.1
   installed : v16.13.1
kusold@Milos-MBP web % npm -v
9.6.4
kusold@Milos-MBP web % n     
     copying : node/12.22.12
   installed : v12.22.12
kusold@Milos-MBP web % npm -v
ERROR: npm v9.6.4 is known not to run on Node.js v12.22.12.  This version of npm supports the following node versions: `^14.17.0 || ^16.13.0 || >=18.0.0`. You can find the latest version at https://nodejs.org/.

ERROR:
/opt/homebrew/lib/node_modules/npm/lib/utils/exit-handler.js:19
  const hasLoadedNpm = npm?.config.loaded
                           ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at module.exports (/opt/homebrew/lib/node_modules/npm/lib/cli.js:42:23)
    at Object.<anonymous> (/opt/homebrew/lib/node_modules/npm/bin/npm-cli.js:2:25)
    at Module._compile (internal/modules/cjs/loader.js:999:30)

Configuration Details

$ n --version
v9.1.0

$ command -v node
/usr/local/bin/node

$ node -p process.platform
darwin

I suspect you have an npm version installed by HomeBrew which is being found earlier in your PATH. To see if you have more than one copy of npm in your PATH run:

which -a npm

There is some code to check for this in n doctor from n v9.1.0. Try running n doctor.

To check what is installed with HomeBrew, run:

brew list

If you want the version of npm installed with node to be active, you could uninstall the HomeBrew managed version.

Ah yup. It was a brew issues. If I remember correctly, I had to install node with brew first due to issues with Apple M2 even though I actively didn't want to. Thanks