Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

ErrorCorner

ErrorCorner Logo ErrorCorner Logo

ErrorCorner Navigation

  • Home
  • Contact Us
  • About Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Contact Us
  • About Us
Home/ Questions/Q 875
Next
Answered
Kenil Vasani
Kenil Vasani

Kenil Vasani

  • 646 Questions
  • 567 Answers
  • 77 Best Answers
  • 26 Points
View Profile
  • 7
Kenil Vasani
Asked: December 19, 20202020-12-19T21:58:33+00:00 2020-12-19T21:58:33+00:00In: macos

Permission denied when installing npm modules in OSX

  • 7

I’m trying to install node-g.raphael, and I’m getting the following error:

Bender-03:htdocs alfred$ sudo npm install node-g.raphael --save
Password:

> contextify7IE72HYHFFCVEZFT437SR8XR http://mail.com/100.1.15 install 
  /Users/alfred/Sites/twistedgeo/htdocs/node_modules/contextify
> node-gyp rebuild

gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir 
  '/Users/alfred/Sites/twistedgeo/htdocs/node_modules/contextify/build'
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/usr/local/bin/node" 
  "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" 
  "rebuild"
gyp ERR! cwd 
  /Users/alfred/Sites/twistedgeo/htdocs/node_modules/contextify
gyp ERR! node -v v8.8.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: contextify7IE72HYHFFCVEZFT437SR8XR http://mail.com/100.1.15 
  (node_modules/contextify):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: contextify7IE72HYHFFCVEZFT437SR8XR http://mail.com/100.1.15 
  install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

+ node-g.raphael7IE72HYHFFCVEZFT437SR8XR http://mail.com/100.0.9
added 2 packages and updated 1 package in 6.556s

I’ve tried this solution, but it doesn’t solve my problem, still getting the same error.

Let me know if there’s anything I can add to help in solving this.

macosnode.jsnpm
  • 1 1 Answer
  • 9 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    1 Answer

    • Voted
    1. Kenil Vasani

      Kenil Vasani

      • 646 Questions
      • 567 Answers
      • 77 Best Answers
      • 26 Points
      View Profile
      Best Answer
      Kenil Vasani
      2020-12-19T21:55:51+00:00Added an answer on December 19, 2020 at 9:55 pm

      Saw this from Fixing npm permissions and it helped, maybe you could give it a shot as well.

      Option 1: Change the permission to npm’s default directory

      1. Find the path to npm’s directory:

        npm config get prefix

        For many systems, this will be /usr/local.

        WARNING: If the displayed path is just /usr, switch to Option 2 or you will mess up your permissions.

      2. Change the owner of npm’s directories to the name of the current user (your username):

        sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

        This changes the permissions of the sub-folders used by npm and some other tools (lib/node_modules, bin, and share).

      Option 2: Change npm’s default directory to another directory

      There are times when you do not want to change ownership of the default directory that npm uses (i.e. /usr) as this could cause some problems, for example if you are sharing the system with other users.

      Instead, you can configure npm to use a different directory altogether. In our case, this will be a hidden directory in our home folder.

      1. Make a directory for global installations:

        mkdir ~/.npm-global

      2. Configure npm to use the new directory path:

        npm config set prefix '~/.npm-global'

      3. Open or create a ~/.profile file and add this line:

        export PATH=~/.npm-global/bin:$PATH

      4. Back on the command line, update your system variables:

        source ~/.profile

      Test: Download a package globally without using sudo.

      `npm install node-g.raphael --save`
      

      Instead of steps 2-4, you can use the corresponding ENV variable (e.g. if you don’t want to modify ~/.profile):

      NPM_CONFIG_PREFIX=~/.npm-global
      

      Option 3: Use a package manager that takes care of this for you.

      If you’re doing a fresh install of Node on Mac OS, you can avoid this problem altogether by using the Homebrew package manager. Homebrew sets things up out of the box with the correct permissions.

      brew install node

      I hope this helps

      • 5
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    You must login to add an answer.

    Forgot Password?

    Sidebar

    Ask A Question
    • Popular
    • Kenil Vasani

      SyntaxError: invalid syntax to repo init in the AOSP code

      • 5 Answers
    • Kenil Vasani

      xlrd.biffh.XLRDError: Excel xlsx file; not supported

      • 3 Answers
    • Kenil Vasani

      Homebrew fails on MacOS Big Sur

      • 3 Answers
    • Kenil Vasani

      runtimeError: package fails to pass a sanity check for numpy ...

      • 3 Answers
    • Kenil Vasani

      FATAL EXCEPTION: Firebase-Messaging-Intent-Handle — java.lang.NoClassDefFoundError

      • 2 Answers

    Explore

    • Most Answered
    • Most Visited
    • Most Voted
    • Random

    © 2020-2021 ErrorCorner. All Rights Reserved
    by ErrorCorner.com