Missing write access to /usr/local/lib/node_modules

I was updating NPM, Node, and Vue (a javascript framework). I think somewhere I changed the permissions to a directory to root root. I am trying to run

npm install -g @vue/cli

I get a string of

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/@vue/

The owner of node_modules was root:root and I changed it to root:staff. I also made sure I was in the staff group. For some reason I am still getting Missing write access. I also chmod 775 -R. And then reboot to make sure the new permissions loaded but still having trouble installing the Vue CLI. What am I doing wrong?

1 Answer

As describe on npm documentation you can:

  1. Back up your computer.
  2. On the command line, in your home directory, create a directory for global installations:mkdir ~/.npm-global

  3. Configure npm to use the new directory path:npm config set prefix '~/.npm-global'

  4. In your preferred text editor, open or create a ~/.profile file and add this line:export PATH=~/.npm-global/bin:$PATH

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

  6. To test your new configuration, install a package globally without using sudo:npm install -g jshint

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like