Setting up NODE_PATH for using global packages via require(…)


Node.js intends global install for applications only. If you want to use some package in your project via require('...') the recommended way is to put them in projects root. However, you may want some packages to install globally via npm install -g package and use them on your node projects. Then, you have to make sure you have the %NODE_PATH% system variable set up to point global node_modules directory, e.g.: %USERPROFILE%\AppData\Roaming\npm\node_modules for Windows 8.

One thought on “Setting up NODE_PATH for using global packages via require(…)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.