I am trying to download an npm package globally, but met with this error. I'm aware that the path where the package is downloaded should be /usr/local/lib/node_modules, but in the error, it seems the path is ../lib/node_modules/nodemon/bin/nodemon.js. I previously downloaded npm/node with Homebrew, but uninstalled it and re-downloaded node through its website.
Node v16.15.0
NPM 8.5.5
MacOS 12.2.1
How can I re-arrange these files so that global packages can be downloaded without this symlink error?
(base) julian@Julians-MacBook ~ % npm install -g nodemon
npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/nodemon/bin/nodemon.js
npm ERR! dest /usr/local/bin/nodemon
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/nodemon/bin/nodemon.js' -> '/usr/local/bin/nodemon'
npm ERR! [Error: EACCES: permission denied, symlink '../lib/node_modules/nodemon/bin/nodemon.js' -> '/usr/local/bin/nodemon'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/nodemon/bin/nodemon.js',
npm ERR! dest: '/usr/local/bin/nodemon'
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