Can't use npm on MacOS Monterey 12.0.1

npm is throwing an error when I attempt to use it in any fashion within the terminal. You should probably upgrade to a newer version of node as we can't make any promises that npm will work with this version. You can find the latest version at https://nodejs.org/ /Users/USERNAME/.nvm/versions/node/v10.15.3/lib/node_modules/npm/lib/npm.js:32 #unloaded = false ^ SyntaxError: Invalid or unexpected token at new Script (vm.js:80:7) at createScript (vm.js:274:10) at Object.runInThisContext (vm.js:326:10) at Module._compile (internal/modules/cjs/loader.js:664:28) at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10) at Module.load (internal/modules/cjs/loader.js:600:32) at tryModuleLoad (internal/modules/cjs/loader.js:539:12) at Function.Module._load (internal/modules/cjs/loader.js:531:3) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:22:18) After googling I came across this issue: npm does not support Node.js v10.19.0 which seems to solve the issue on linux. Maybe there is a way to translate that solution to something that works on MacOS but unfortunately I don't know how. Even after updating Node.js on https://nodejs.org/ am still receiving the same exact error above. I have a hunch that this is caused by some problem relating to xcode after updating to Monterey, but may be wrong. I'm very unfamiliar with npm and node.js so excuse me if I've made any false assumtions.


Try using NVM to install and manage your Node versions. Works great on Mac. https://www.linode.com/docs/guides/how-to-install-use-node-version-manager-nvm/