0

When I run my node.js application as Windows Service using node-windows I have the problem. My appliction can't read files with absolute paths like

var filePath = "C:\\someFolder\\someFile.json";

When I run my node.js application from console using node server.js all works great. Where is problem?

Astemir Almov
  • 396
  • 2
  • 16

1 Answers1

0

This is probably a permissions issue. When you run the application from the console, it inherits the permissions of the user running the script. When you run it from node-windows, it inherits the permissions of the user running the daemon (which commonly defaults to an unprivileged system user).

Check the permissions of the user assigned to run the service. Make sure they have read access to the directories/files you need to access.

Corey
  • 5,133
  • 3
  • 23
  • 24
  • I've been struggling with this same issue. I have configured the service to run with the same Administrator account that I use to run the standalone node process. However when running from within `node-windows` it complains about the path `"Y:\\M3OUT\\M3PDF_PRD\\FACTURAS"` (which is a network drive). Any ideas? Thanks for a such a great tool! – arielf Dec 20 '17 at 19:40
  • Windows does not read network drives in the same manner as local drives. I don't know specifics, but I would troubleshoot by first testing node-windows with a local drive, then move onto a network drive. Also, make sure your admin account has proper permissions to the network drive. – Corey Dec 21 '17 at 01:14
  • I solved it by using a network path rather than a local drive. Thanks! – arielf Dec 22 '17 at 16:06