-2

I am trying to download nodemon and am quite unsure why it is not downloading. I have got the following error?

npm install -g nodemon

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/nodemon
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/nodemon'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/nodemon'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/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
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.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/ryandevasia/.npm/_logs/2021-12-04T05_47_29_366Z-debug.log

What must be done to download the module?

ryan
  • 69
  • 1
  • 9

2 Answers2

1

The EACCES error means that npm does not have permissions to install global packages. To do this, you'll need to run the command as root (which has permission for the npm global directory) with sudo. So you can run sudo npm install -g nodemon with an administrator account and it will work, after you enter your password.

SealsRock12
  • 161
  • 2
  • 13
  • I happen to have the same problem with downloading sqlite3 with npm would sudo work with that – ryan Dec 04 '21 at 06:13
  • It should work with globally installing anything. But if it's a library that a project depends on, you should install it locally. Global stuff is for CLIs and other tools (like nodemon). – SealsRock12 Dec 04 '21 at 06:14
0

Try installing with sudo:

sudo npm install -g nodemon

Usually it's better to install nodemon as a dev dependency with

npm i -d nodemon

That way you can build it into your scripts and it helps with collaboration:

"start" : "nodemon index.js"
DᴀʀᴛʜVᴀᴅᴇʀ
  • 7,681
  • 17
  • 73
  • 127
  • You may want to install nodemon globally if you are working on multiple js files in one npm project or js files outside of an npm project. – SealsRock12 Dec 04 '21 at 15:44
  • I've always found working on a project with multiple people it was complicated trying to replicate an environment so building it as a dependency and adding as a script works better. – DᴀʀᴛʜVᴀᴅᴇʀ Dec 04 '21 at 18:14