1

I have developped a little app in NodeJs which read and write some files. These files are stored on a shared folder of my local network. Everything was working until I tried to start NodeJs as Windows Service through NSSM (a little .exe that allows you to transform a .bat to a Windows Service).

In fact, fs.readFile doesn't work anymore so i can't use it, and i don't see where does the problem come from. In addition, fs.existsSync("\\\\10.200.10.1\\reporting\\") returns false, but fs.existsAsync("\\\\10.200.10.1\\reporting\\") returns true. I also tried some other functions like fs.access and it doesn't work either.

I would be grateful if someone could tell me how i can make this work. I don't really care about NSSM, my only goal is to make my Node App works as Windows Service, so if an other tool can resolve my issue, let's tell me.

I don't know if it's the same problem, but I have an other thing which doesn't work in service mode : Execute VBS from Nodejs in background mode (Tasks Scheduler or Windows Service)

Holgrabus
  • 141
  • 2
  • 9
  • What is `fs.existsAsync()`? – jfriend00 Nov 05 '19 at 16:52
  • This is the async version of fs.existsSync. I know these functions are deprecated but they are still working. – Holgrabus Nov 06 '19 at 08:27
  • Can you show us your real code? I ask because `fs.existsSync(\\10.200.10.1\reporting\) ` isn't legal Javascript as there's no quotes around the path name. And, if you did have quotes around this, it would need to be `fs.existsSync("\\\\10.200.10.1\\reporting\\")` to get the escaped backslashes correct. Windows path names are a pain in Javascript strings because of the use of backslash. – jfriend00 Nov 06 '19 at 09:25
  • Yes it's "\\\\10.200.10.1\\reporting\\", but i actually use a variable string. And I also tried with the drive key "N:\\\\" but nothing has changed. – Holgrabus Nov 07 '19 at 08:24
  • Did you set a logon account for your service that has proper permissions to those network resources? Did you configure networking as a dependent service (so you're sure networking is available when your service gets started)? – jfriend00 Nov 07 '19 at 15:37
  • If trying the `N` drive, the proper Javascript string would just be `"N:\\"`, not `"N:\\\\"`. – jfriend00 Nov 07 '19 at 15:38
  • I tried with N:\\\ and N:\\ but the result is the same. I use the same account/password than my windows session, and i can access to it through explorer. – Holgrabus Nov 08 '19 at 08:29
  • If you use `fs.access()` with a callback, what is the exact error you get? – jfriend00 Nov 08 '19 at 08:33
  • I tried with another file :[2019-11-08T08:48:49.027Z] { Error: ENOENT: no such file or directory, access 'I:\Passwords.xls' errno: -4058, code: 'ENOENT', syscall: 'access', path: 'I:\\Passwords.xls' } – Holgrabus Nov 08 '19 at 08:49
  • With IP : [2019-11-08T08:48:49.074Z] { Error: UNKNOWN: unknown error, access '\\10.200.10.1\Info\Passwords.xls' errno: -4094, code: 'UNKNOWN', syscall: 'access', path: '\\\\10.200.10.1\\Info\\Passwords.xls' } – Holgrabus Nov 08 '19 at 08:51
  • Did you found the solution for this ? I'm having the same problems. I know there has to be some Logon permissions, but I'm not sure what user should I use for this – Janx from Venezuela Nov 17 '20 at 15:58
  • Sorry, i didn't found any solution for this. I noticed some problems with NodeJS in background mode, so i use now PM2 to start the app and still make it invisible. Unfortunatly, the session must be opened. – Holgrabus Nov 17 '20 at 23:26
  • The security of your local user is different than the windows process. It doesn't have access to the passwords necessary to access shared path (UNC) – Alex Parij Feb 24 '23 at 15:47

0 Answers0