Movatterモバイル変換


[0]ホーム

URL:


Skip to searchSkip to content

Site navigation

If you see anEACCES error when you try toinstall a package globally, you can either:

  • Reinstall npm with a node version manager (recommended),

    or

  • Manually change npm's default directory

Reinstall npm with a node version manager

This is the best way to avoid permissions issues. To reinstall npm with a node version manager, follow the steps in "Downloading and installing Node.js and npm". You do not need to remove your current version of npm or Node.js before installing a node version manager.

Manually change npm's default directory

Note: This section does not apply to Microsoft Windows.

To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, you will create and use a hidden directory in your home directory.

  1. Configure npm to use the new directory path:

    npm config set prefix ~/.local
  2. In your preferred text editor, open or create a~/.profile file and add this line:

    PATH=~/.local/bin:$PATH

    If you are using zsh (which you can find out by runningecho $0), you will also need to add this line to~/.zprofile:

    source ~/.profile
  3. On the command line, update your system variables:

    source ~/.profile
  4. To test your new configuration, install a package globally without usingsudo:

    npm install -g npm-check-updates

    And run it:

    ncu -g

npx: an alternative to running global commands

If you are using npm version 5.2 or greater, you may want to considernpx as an alternative way to run global commands, especially if you only need a command occasionally. For more information, seethis article about npx.

Edit this page on GitHub
7 contributorsmohd-akramdnhnmdsadiqlukekarrysmrienstralaurensvalkethomson
Last edited bymohd-akram onSeptember 15, 2025

[8]ページ先頭

©2009-2025 Movatter.jp