isaacs/nave

global module location

domtra opened this issue · 3 comments

Hi there. This is more a question rather than an issue.

Is it intended, that when you only switch minor or patch versions of node, that you need to reinstall all global npm modules?

For me it used to be different before I wiped and re-setup my machine. Now, let's say I am using v8.14.0 and install a global package it will correctly make the binaries available in my PATH. However, when I update node to v8.14.1, these binaries will not be available anymore. I have to reinstall the package globally again.

It would be really nice, if at least patch versions would share a global directory.

I am using zsh and nave use x will add the following env variables:

NAVE=8.14.0
NAVELVL=1
NAVENAME=8.14.0
NAVEPATH=/Users/xxx/.nave/installed/8.14.0/bin
NAVEVERSION=8.14.0
NAVE_DIR=/Users/xxx/.nave
NAVE_LOGIN=1
NAVE_ROOT=/Users/xxx/.nave/installed
NAVE_SRC=/Users/xxx/.nave/src
NODE_PATH=/Users/xxx/.nave/installed/8.14.0/lib/node
PATH=$PATH:/Users/xxx/.nave/installed/8.14.0/bin:/Users/xxx/bin
npm_config_binroot=/Users/xxx/.nave/installed/8.14.0/bin
npm_config_manroot=/Users/xxx/.nave/installed/8.14.0/share/man
npm_config_prefix=/Users/xxx/.nave/installed/8.14.0
npm_config_root=/Users/xxx/.nave/installed/8.14.0/lib/node

Yes, because modules can be compiled for a specific version of node - global modules shouldn’t be shared across node versions.

Yes, this is by design. There are two workarounds that most people rely on.

  1. Don't install the global module in the Nave subshell. (Ie, install it in your "main" root.)
  2. Don't use global modules. (Ie, rely on npx and package.json scripts stanzas to use locally installed executables.)
ukabu commented

Any suggestion to manage the npm version? It would be really nice to be able to not only specify node version but also the npm version.