nvm: $NODE_PATH is not being set, so it can not find global modules

For whatever reasons, nvm is not setting correct NODE_PATH, and hence my builds can not find the globablly installed modules.

my app does this require('ibrik') but it fails, even if the ibrik is installed globally

I think this is same problem as http://stackoverflow.com/questions/27876557/node-js-configuring-node-path-with-nvm

Am i supposed to set it manually ?

MacBook-Pro:coffee sudhir$ nvm ls
->       v6.3.1
default -> 6.3.1 (-> v6.3.1)
node -> stable (-> v6.3.1) (default)
stable -> 6.3 (-> v6.3.1) (default)
iojs -> N/A (default)
lts/* -> lts/argon (-> N/A)
lts/argon -> v4.4.7 (-> N/A)
MacBook-Pro:coffee sudhir$ nvm use 6.3.1
Now using node v6.3.1 (npm v3.10.3)
MacBook-Pro:coffee sudhir$ which npm
/Users/sudhir/.nvm/versions/node/v6.3.1/bin/npm
MacBook-Pro:coffee sudhir$ which node
/Users/sudhir/.nvm/versions/node/v6.3.1/bin/node
MacBook-Pro:coffee sudhir$ echo $NODE_PATH
<EMPTY>
MacBook-Pro:coffee sudhir$ npm ls -g -depth 0
/Users/sudhir/.nvm/versions/node/v6.3.1/lib
├── bower@1.7.9
├── coffee-script@1.10.0
├── grunt-cli@1.2.0
├── ibrik@2.0.0
├── karma-cli@1.0.1
└── npm@3.10.3

This is my exact problem - https://github.com/karma-runner/karma-cli/issues/22 Not sure if its problem because of nvm or its a karma bug

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 23 (10 by maintainers)

Commits related to this issue

Most upvoted comments

This is intentional. NODE_PATH should never be set, and global modules both are not requireable by default, and should never be required. Something you require is a dependency, and thus, must be installed locally.

@dustinaleksiuk typically using a shrinkwrap file also means every consumer has to be on the same OS (when you have compiled deps).

why though? sometimes it does make sense to install and use global dependencies outside of the scope of a project especially if you’re using it in a repl. there are many points of common functionality from parsing files of specific types to outputting in specific ways that could be common. it feels rather arbitrary to say to never use a part of npm.

Thansk for clarifying, karma-coverage asks to use ibrik 2… i will try to get help from them… thanks

It looks like v1 did in fact have a “main” - https://npmcdn.com/ibrik@1.1.1/package.json - so I think you’re just using the wrong version of ibrik. I’d file the issue on karma-coverage - it’s definitely not related to nvm.