NodeJS require a global module/package

In Node.js, require doesn’t look in the folder where global modules are installed.

You can fix this by setting the NODE_PATH environment variable. In Linux this will be:

export NODE_PATH=/usr/lib/node_modules

Note: This depend on where your global modules are actually installed.

See: Loading from the global folders.

Leave a Comment