0

Simply, trying to

npm install -g something

something and in node

let c = require('something')

says that it

Cannot find module 'something'

However, I don't think I've messed around with any node/npm paths.

I can fix this by running

export NODE_PATH=$(npm root -g)

(which is /usr/local/lib/node_modules)

But I am wondering why I have to do this in the first place. What is the default NODE_PATH that node is looking at, that I am changing to npm root -g?

I'm on macOS Catalina running the latest versions of npm and node

To summarize, my question is just about why this behavior is happening. I already have a described the workaround for this, but you would think that node would use npm root -g as its default global req path by default.

Max Coplan
  • 1,111
  • 13
  • 27
  • Maybe geting rid of your global modules and set it up again helps, though not best solution – Jora Dec 24 '19 at 23:55
  • I followed the first answers responses to [this](https://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x) and tested again before posting this – Max Coplan Dec 25 '19 at 00:08

0 Answers0