Closed dmitriz closed 8 years ago
I have investigated it further and the following summarised entry updates both PATH and NODE_PATH work:
# Move global node modules to local directory
NPM_PACKAGES=~/.npm-packages
export NODE_PATH=$NPM_PACKAGES/lib/node_modules:$NODE_PATH
export PATH=$PATH:$NPM_PACKAGES/bin
PATH
still seems to be updated without export
but NODE_PATH
doesn't.
The setup actually seems to work without NODE_PATH
, I could not find any documentation on it.
It looks like the setting in .npmrc
is enough for Node to know where to install global packages, and no
further NODE_PATH
setting seems to be needed. At least it works on my machine like that.
You're right. I've done some tweaks. PATH
doesn't need to be exported as it already is in all shells.
You can also remove step 2 if you rename NPM_PACKAGES
to NPM_CONFIG_PREFIX
. :wink:
@Rowno I know. It was deliberate. I think it's better to keep it in .npmrc
so it will work when npm is run outside the shell too.
I have another question. I successfully changed my dir, but when I install latest npm package it saves it in the Profile dir ~/.npm-packages
and the terminal finds the old version which is still located in /usr/bin/
?
@elpiel Did you solve your issue? I have the same.
I'm not using MacOS anumore @saulius-spiridonas-ht . Problem solved 😹
On my Mac OS 10.10.5 the settings from https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md still did not update the path, so I had to add this to my
.bash_profile
:export PATH=~/.npm-packages/bin:$PATH