1

I'm getting the following error when trying to do anything with npm:

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '../lib/utils/unsupported.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:153:3)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)

I can't run npx create-react-app or any npm commands including uninstalling or updating npm. Yesterday I installed yarn, could that be part of the problem? I also updated my Mac to Catalina 10.15.5 recently. I'm not sure if either/both of these caused the npm issue or not.

What's causing this and how can I fix it?

RobC
  • 22,977
  • 20
  • 73
  • 80
Nick Kinlen
  • 1,356
  • 4
  • 30
  • 58

1 Answers1

1

Found a solution. A modified version of this answer worked.

I ran:

brew uninstall --force node

sudo rm -r /usr/local/lib/node_modules

brew install node

and that did the trick.

Nick Kinlen
  • 1,356
  • 4
  • 30
  • 58