-3

I try to install maven locally using npm install maven and then run it in terminal and it says mvn command not found and so I then try to install it globally using npm install maven -g and I'm getting an error:

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/maven
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/maven'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/maven'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/maven'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

I'm on macOS 13.2.1.

I've run the command with sudo and it looks like it installs but still the command mvn command not found is not found.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
1.21 gigawatts
  • 16,517
  • 32
  • 123
  • 231
  • 1
    Why are you trying to install Maven via NPM? See https://maven.apache.org/install.html or use e.g. https://formulae.brew.sh/formula/maven – jonrsharpe Mar 19 '23 at 18:58
  • @jonrsharpe why can't you install it with npm? – 1.21 gigawatts Mar 19 '23 at 18:59
  • 1
    ...because that's not where it's published? Why did you think you _could_?! You're trying to install https://www.npmjs.com/package/maven, which is a _wrapper library_ for using Maven from JS (and seems a bit out of date). – jonrsharpe Mar 19 '23 at 19:03
  • @jonrsharpe I see that it is a wrapper. I've found the downloads you've linked to. Although, with brew, it says it requires an update and that requires an update of XCode but maven installed before the brew update exited (at python install). – 1.21 gigawatts Mar 21 '23 at 17:30

1 Answers1

0

One possible fix is:

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

You can find more informations about this issue in this similar question.

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
Witer33
  • 9
  • 1