Npm Change $Path Isn't Perminent, Only per Terminal?

Recently I have changed OS to Linux Ubuntu for development. I have installed Node.js & NPM to use with Yeoman, after installing NPM I followed the official documentation on permissions Docs. As my displayed path was just /usr i followed Option 2. Everything went well and I proceeded to install Yeoman, Bower & Grunt and everything was fine. However Yeoman, Bower & Grunt do not work in another terminal window. each time I open a terminal I must follow Option 2 again before I can commence usage. Why isn’t my $PATH staying updated? What am I doing wrong?

Also, while im asking. NPM is running like a snail while installing, it took me probably around 5 hours to install Yeoman, Bower, Grunt & Webapp-gen and it took around a hour to make a new project yo webapp last night. Anyone know why this may be? it's still running like a snail today - Internet & hardware usage are all normal and in the green, git, composer, bower etc are all running at normal speed. Its just NPM.

makka@ML:~$ node --version && npm --version && git --version && yo --version && bower --version && grunt --version
v5.4.1
3.5.3
git version 2.5.0
yo: command not found
makka@ML:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
makka@ML:~$ cd //usr/local && ls -la
total 40
drwxr-xr-x 10 root root 4096 Oct 21 16:49 .
drwxr-xr-x 12 root root 4096 Jan 18 00:14 ..
drwxr-xr-x  2 root root 4096 Jan 18 01:22 bin
drwxr-xr-x  2 root root 4096 Oct 21 16:49 etc
drwxr-xr-x  2 root root 4096 Oct 21 16:49 games
drwxr-xr-x  2 root root 4096 Oct 21 16:49 include
drwxr-xr-x  5 root root 4096 Oct 21 17:00 lib
lrwxrwxrwx  1 root root    9 Jan 17 20:27 man -> share/man
drwxr-xr-x  2 root root 4096 Oct 21 16:49 sbin
drwxr-xr-x  8 root root 4096 Oct 21 17:00 share
drwxr-xr-x  2 root root 4096 Oct 21 16:49 src
makka@ML://usr/local$ ls -la ~/
total 188
drwxr-xr-x  23 makka makka  4096 Jan 18 16:19 .
drwxr-xr-x   3 root  root   4096 Jan 17 20:31 ..
drwx------   3 makka makka  4096 Jan 18 02:57 .adobe
-rw-------   1 makka makka  3012 Jan 18 16:46 .bash_history
-rw-r--r--   1 makka makka   220 Jan 17 20:31 .bash_logout
-rw-rw-r--   1 makka makka    43 Jan 18 05:01 .bash_profile
-rw-r--r--   1 makka makka  3771 Jan 17 20:31 .bashrc
drwx------  22 makka makka  4096 Jan 18 03:59 .cache
drwxrwxr-x   2 makka makka  4096 Jan 18 01:20 .composer
drwx------  24 makka makka  4096 Jan 18 05:46 .config
drwxr-xr-x   3 makka makka  4096 Jan 18 05:48 Desktop
-rw-r--r--   1 makka makka    25 Jan 17 20:56 .dmrc
drwxr-xr-x   2 makka makka  4096 Jan 17 20:56 Documents
drwxr-xr-x   4 makka makka  4096 Jan 18 02:16 Downloads
-rw-r--r--   1 makka makka  8980 Jan 17 20:31 examples.desktop
drwx------   3 makka makka  4096 Jan 18 16:19 .gconf
drwx------   3 makka makka  4096 Jan 18 00:01 .gnome
-rw-------   1 makka makka   604 Jan 18 16:19 .ICEauthority
drwx------   3 makka makka  4096 Jan 17 20:56 .local
drwx------   3 makka makka  4096 Jan 18 02:57 .macromedia
drwx------   4 makka makka  4096 Jan 17 23:31 .mozilla
drwxr-xr-x   2 makka makka  4096 Jan 17 20:56 Music
drwxrwxr-x   3 makka makka  4096 Jan 18 02:58 .node-gyp
-rw-rw-r--   1 makka makka    23 Jan 18 04:55 .node_repl_history
drwxr-xr-x 823 makka makka 36864 Jan 18 02:58 .npm
drwxrwxr-x   5 makka makka  4096 Jan 18 00:48 .npm-global
-rw-------   1 makka makka    21 Jan 18 05:19 .npmrc
drwxr-xr-x   2 makka makka  4096 Jan 17 20:56 Pictures
drwx------   3 makka makka  4096 Jan 18 00:01 .pki
-rw-r--r--   1 makka makka   675 Jan 17 20:31 .profile
drwxr-xr-x   2 makka makka  4096 Jan 17 20:56 Public
-rw-r--r--   1 makka makka     0 Jan 17 20:57 .sudo_as_admin_successful
drwxr-xr-x   2 makka makka  4096 Jan 17 20:56 Templates
drwxr-xr-x   2 makka makka  4096 Jan 17 20:56 Videos
-rw-------   1 makka makka    47 Jan 18 16:19 .Xauthority
-rw-------   1 makka makka  1576 Jan 18 16:19 .xsession-errors
-rw-------   1 makka makka  2804 Jan 18 16:16 .xsession-errors.old
makka@ML://usr/local$ npm config set prefix '~/.npm-global'
makka@ML://usr/local$ export PATH=~/.npm-global/bin:$PATH
makka@ML://usr/local$ source ~/.profile
makka@ML://usr/local$ node --version && npm --version && git --version && yo --version && bower --version && grunt --version
v5.4.1
3.5.3
git version 2.5.0
1.6.0
1.7.2
grunt-cli v0.1.13
makka@ML://usr/local$ echo $PATH
/home/makka/.npm-global/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

Many thanks, Regards, Matt

1 Answer

Looks like you aren't putting your export command into ~/.profile.

echo   export PATH=~/.npm-global/bin:$PATH > ~/.profile
source ~/.profile
9

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest