I have two servers running nodejs applications. I did some setting with the first one before. After that setting, when I start the command line, if I run node
command, I see the service is running.
But I do not remember what I did. So in my second server, anytime I restart command line session, when I type node
I get -bash: node: command not found
.
Could anyone remind me please?
NOTE: Please don't tell me this is duplicate. Search for keywords "start, node service, automatically, etc." most of them tell about the use of 'forever'. I know forever (gdi), mine is a lot more stupid question and I don't know the correct terminology just yet.
I would recommend installing your node. js app as a Windows service, and then set the service to run at startup. That should make it a bit easier to control the startup action by using the Windows Services snapin rather than having to add or remove batch files in the Startup folder.
I would suggest using pm2 or forever
For pm2
do the following
Install it using
npm install pm2 -g
-g installs it globally. Then do following
pm2 start app.js --name="api"
Once that is done, you can do pm2 list
to view all running services as follows
Make pm2 start at boot time
pm2 startup
This will automatically start your node.js app.
Works for my 4 apps that are in production.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With