'npm unresponsive after upgrading to latest version

Working on Mac.

I followed the advice of the command line prompt to upgrade my npm globally with npm install -g npm, but since doing this it seems that my NPM is totally broken...

When loading a new Terminal I get the following message immediately, before typing anything in:

npm does not support Node.js v11.3.0
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/v11.3.0/lib/node_modules/npm/lib/npm.js:32
  #unloaded = false
  ^

SyntaxError: Invalid or unexpected token
    at new Script (vm.js:83:7)
    at createScript (vm.js:267:10)
    at Object.runInThisContext (vm.js:319:10)
    at Module._compile (internal/modules/cjs/loader.js:685:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Module.require (internal/modules/cjs/loader.js:658:17)
    at require (internal/modules/cjs/helpers.js:22:18)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v11.3.0 --silent` to unset it.

I have tried running the commands it suggests:

  • npm config delete prefix doesn't really do anything, just returns to the next terminal line
  • nvm use --delete-prefix v11.3.0 --silent returns the same message as above, twice.

The same message appears when trying to run npm --version...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source