0
votes

I get the following error when setting up a new Vue project:

npm install -g @vue/cli

Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

2
Always use sudo when installing global node packages.Constantin Chirila

2 Answers

2
votes

I got around this error by changing permissions for two directories:

Set permissions to Everyone - Read / Write for

  • /usr/local/lib/node_modules
  • /usr/local/bin

    1. Open Finder.
    2. Press Command +Shift+G. A dialog box opens.
    3. Enter the path and click Go
    4. Right-click the directory and select Get Info
    5. Click the lock icon to allow changes and enter your credentials
    6. In the Sharing & Permissions section change everyone to Read & Write
    7. Click the cog icon and select Apply to enclosed items from the drop down
    8. Confirm the prompt

Reference Article: https://forum.vuejs.org/t/vue-cli-installation-fails-on-macos-mojave-10-14/45712/5

1
votes

As far as I know, its not just a Vue Cli issue but can happen for any node module.

Often this happens if you installed NPM as an administrator or using Sudo. You can usually get around it by doing something like sudo npm install xxx-package-xxx But that really just compounds the problem down the road when lots of things need elevated privileges.

In my case uninstalling and re-installing Node + NPM with a new package (not the ones included with MacOS) kind of helped but I eventually ended up nuking my OS and installing everything fresh.