Skip to content

This script fixes the issues encountered when you are required to use 'sudo' to install npm global packages.

License

Notifications You must be signed in to change notification settings

baxy/npm-global-no-sudo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

npm-global-no-sudo

This script fixes the issues encountered when you are required to use 'sudo' to install npm global packages. The fix consists in creating a new local directory for global packages (default: ~/.npm-packages), configure node to use it and fix permissions. Existing global packages will be backed up and reinstalled after the fix.

The script is an improved version of npm-g_nosudo, based on the guide npm-global-without-sudo.

Usage:

Download:
wget https://raw.githubusercontent.com/baxy/npm-global-no-sudo/master/npm-global-no-sudo.sh

or

curl -O https://raw.githubusercontent.com/baxy/npm-global-no-sudo/master/npm-global-no-sudo.sh
Make executable:
chmod +x npm-global-no-sudo.sh
Run:
./npm-global-no-sudo.sh

Important

  1. After updating your environment files, you will need to source the corresponding file before your npm binaries will be found in the current terminal session, e.g. for bash:

    source ~/.bashrc
    
  2. If NPM needs to be updated, sudo is still required:

    sudo npm install -g npm@latest
    
  3. The script may cause issues if Node Version Manager is found installed. In this case it will exit and do nothing.

License

MIT © Adrian Sabau

About

This script fixes the issues encountered when you are required to use 'sudo' to install npm global packages.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages