npm install: Error: EACCES: permission denied, mkdir

后端 未结 4 1865
清歌不尽
清歌不尽 2021-02-03 14:46

I attempted to do a sudo npm install -g appium on Mac OS 10.12.5.

I get this error:

info Chromedriver Install Installing Chromedri

相关标签:
4条回答
  • 2021-02-03 14:55

    I reinstalled Node/NPM. Problem solved.

    0 讨论(0)
  • 2021-02-03 15:10

    you are using npm so you have to use

    sudo npm install --unsafe-perm
    In unsafe mode with every command you run
    hopefully, it will help

    0 讨论(0)
  • 2021-02-03 15:11

    The -g option means install globally. When packages are installed globally, EACCES permission errors can occur.

    Consider setting up npm to operate globally without elevated permissions. See Resolving Permission Errors for more information.

    Option 1

    The best way to avoid permission issues is to reinstall NodeJS and npm using a node version manager.

    1. Install nvm

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
    

    You can close and reopen the terminal ou just open another terminal and check if nvm is installed properly with this command: command -v nvm.

    2. To download and install the latest LTS release of NodeJS, run:

    nvm install --lts
    

    3. Set the newly installed NodeJS as the default environment:

    nvm alias default lts/*
    

    Option 2 (Does not apply for windows)

    Change the owner of npm's directories to the current user:

    sudo chown -R $(your_user) /usr/local/{lib/node_modules,bin,share}
    sudo chown -R $(your_user) ~/.npm ~/.npmrc
    
    0 讨论(0)
  • 2021-02-03 15:13

    sudo npm install -g appium --unsafe-perm=true --allow-root

    Worked for me

    0 讨论(0)
提交回复
热议问题