Fixing npm permission issue

Kaustubh Talathi
1 min readJul 9, 2016

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:

This can be resolved by following methods:

Appending sudo:

  • sudo npm install
  • enter system password

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/

Navigate to your application folder where your local node_modules reside.

  • Run the similar command
  • sudo chown -R <user_id> node_modules/

“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.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet