Fixing npm permission issue

Node and npm can be installed easily. However, we might face issues while using npm. Most of the time this mean that we don’t have access to install the files on the machine. This can be resolved by appending sudo command but it is not recommended as it might create other issues. If the user does not have permissions to install file and “npm install” is ran on the terminal; we’ll see the following screen:

Screen Shot 2016-07-09 at 4.49.39 PM

This can be resolved by following methods:

  1. Appending sudo:
    • sudo npm install
    • enter system password
  2. Changing the permission on global and local folders where the node modules reside:
    • Run “npm config get prefix” in your terminal. This will give the path of global node_modules: For ex: /usr/local
    • Change the user permissions for this folder by using following command:
      • sudo chown -R <user_id> /usr/local/

  3. Navigate to your application folder where your local node_modules reside.
    • Run the similar command
      • sudo chown -R <user_id> node_modules/
  4. “npm install” should work on this application from now onwards.

PS: Repeat Step 3. in case of a different project.

For more information and alternatives visit Fixing npm permissions.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s