EACCES: permission denied with fs-extra only using nodemon
Asked Answered
P

0

7

I am attempting to use the move method from the fs-extra npm module. It works for moving files and empty directories, but every time I try to move a non-empty directory while using nodemon, I get this error:

[Error: EACCES: permission denied, rename 'path/to/src/dir' -> 'path/to/dest/dir'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'rename',
  path: 'path/to/src/dir',
  dest: 'path/to/dest/dir'
}

However, if I try to use the exact same method with good ol' fashioned node index.js, it works with flying colors. Why does nodemon not have sufficient permissions and how do I fix it?

I have tried:

  • Installing nodemon with sudo
  • Installing nodemon without sudo
  • Each of the first two but running nodemon with sudo
  • Each of the first two but running nodemon without sudo

EDIT:

Because of @Aw Snap's comment, I tried it on Mac OS and it seems to work even with nodemon.

I wonder if this is a problem specifically with the Windows Subsystem for Linux...

Peevish answered 20/8, 2020 at 8:39 Comment(8)
which OS are you using?Ellamaeellan
Windows debian subsystem (wsl)Peevish
Maybe nodemon drops privileges calling node in your environment ? To verify add code to your app to create a file in a directory where everybody has access to. Then start your app and check the permissions of the created file.Sibley
Are you using powershell ?Wrecker
absolutely YES. Windows is not a choice to develop modern apps. Also if you are developing a nodejs app, common environment is linux, no windows nor mac , so I advice to install linux. This distro is very good for developers like us elementary.io In another way, could you upload a minimal version of your app maybe in github? This will help us to help you. Did you try in linux? If works in linux, nothing else should interest youAkeyla
@Wrecker no, Windows Terminal: github.com/Microsoft/TerminalPeevish
@Sibley It is just my current User who owns it and there are full permissions on the file created. Note that even moving empty folders does work, it is just moving ones with files in them that gives the error.Peevish
@Akeyla I will try and build a minimal version. I will also eventually try on Linux, but right now the question is addressing the problem in Windows SL, so the solution would have to fix it in Windows SL.Peevish

© 2022 - 2024 — McMap. All rights reserved.