Replies: 3 comments 1 reply
-
Maybe you don’t have permission to open this file |
Beta Was this translation helpful? Give feedback.
-
This will be helpful of your service.
These steps should help ensure your app can access the .env file and function properly when running as a Windows service. |
Beta Was this translation helpful? Give feedback.
-
Thanks. I have tried setting NSSM to launch a .bat file and also tried launching with:
I have tried setting the service to run as LOCALSYSTEM, and have tried running it as a domain user. I have tried pasting the contents of the .env file into NSSM as environment variables. I will try setting the service to run as a local user. How would I launch it with PM2? Would it be:
? |
Beta Was this translation helpful? Give feedback.
-
Hello,
I have an npm app running successfully on my Windows 2022 server, launching it with command:
npm run start:production
I configured it to run as a Windows service using NSSM ( https://github.com/treeswift/nssm ) , NSSM is set up to launch:
"C:\Program Files\nodejs\npm.cmd" run start:production
The app launches OK this way, but users complain that they aren't able to authenticate to external website APIs, as if it wasn't reading the API keys correctly that are in the .env file.
Is it possible to launch npm apps as a Windows service?
If so, what is the best way to run npm apps as a Windows service, using NSSM or some other method? Should I be launching a .bat file, or running npm with arguments, running as LOCALSYSTEM or as a local user, etc.?
Beta Was this translation helpful? Give feedback.
All reactions