Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Globally installed npm package not accessible in terminal

I installed protractor through npm install -g protractor which run successfully.

Running npm -g ls --depth=0 shows protractor installed correctly.

azim@azim-desktop:~$ npm -g ls --depth=0
/home/azim/npm-global/lib
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

but protractor isn't accessible in terminal.

azim@azim-desktop:~$ protractor
protractor: command not found

It was working fine a while ago, I've updated my npm and node to latest versions. I think after that the PATH variables messed up. Googled for a solution but didn't work anything. I don't want to mess up the current situation.

Current path is:

azim@azim-desktop:~$ echo $NODE_PATH
/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript:/home/azim/npm-global/lib/node_modules

Versions:

azim@azim-desktop:~$ npm --version
2.14.12
azim@azim-desktop:~$ node --version
v4.3.1
like image 348
Asim K T Avatar asked Oct 25 '25 05:10

Asim K T


1 Answers

The environment variable $NODE_PATH is used by node to look for modules only.

Essentially you'll want to make sure that the directory path, where the protractor binary is located, is accessible through the environment variable $PATH instead.


Example of where my protractor is installed:

root@codeblog:~# which protractor
/usr/bin/protractor

root@codeblog:~# env | grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript

If you got protractor installed at another place then you might want to tweak your ~/.bashrc to append that directory into the $PATH variable.

Like:

PATH=$PATH:/usr/my_protractor_dir/bin
like image 89
Samuel Toh Avatar answered Oct 26 '25 20:10

Samuel Toh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!