Forever is not recognized as a internal or external command - node.js

Basically i'm a linux user. For the first time i'm running my node.js application in windows machine. I want to run my application as background process.
So installed forever globally npm install forever -g. Now i tried to run my node application using forever start app.js.
I am receiving error as forever is not reconised as internal or external command.
I tried setting the ENV varibales pointing to bin folder of forever. But still im getting the error.
OS:Windows 7
Please share your ideas.
Package.Json
{
"Name":"xxxx",
"version":"1.0.0",
"dependencies":{
"async":"^2.5.0",
"forever":"^0.15.3"
}
}
Node version: 8.9.3
npm version:5.5.1

Related

Pm2 starts the process but node app inaccessible

I'm new to PM2 and nodejs, I'm trying to learn node by following simple sample that creates a server that displays 'Hello World' from the browser. Please note that I'm running node on QNAP NAS. I have successfully installed nodejs, npm, and pm2. when I run app.js via node app.js, it works and I see the message using the port specified.
but when I run via pm2 start app.js, I got this
Then after a few seconds I got status = errored
when I look at the log I got this.
I tried searching in google but the result were pointing to old version of node which I don't
Node itself has to be built with inspector. You can try to install LTS version of node.
Alternatively, you can try installing node-inspector with npm i node-inspector --save

NestJS server dies when console is closed?

I created folder for project, copy package.json and run npm install, build locally nestjs project and copy dist into server. Then ran in console node dist/main.js. For testing I used a base NestJS project (nest new ...) which only return "Hello word" on 3000 port.
Server work fine, but after close of console will stop.
I think problem on VPS (Ubuntu) settings or may be need to add some parameters to NestJS.
Why it not work constantly?
Thanks in advance for any advice.
I resolved problem with npm forever - https://www.npmjs.com/package/forever
install it globally - npm install forever -g
then got to project dir and run - forever start dist/main.js
Seems all work fine.

Nodejs automatically shuts after running for some time

My environment is ubuntu 16.04 with npm 5.0.0 and node 8.0.0 installed. I created an express application and started it with nohup npm start & in the application root directory. However, a couple of minutes later the app became unreachable and the process was lost. I tried restarting several time but the process always automatically exits. How can I start a long-running nodejs app?
Use pm2 daemon for setting Up a Node.js Application for Production on Ubuntu 16.04
Follow commands
sudo npm install -g pm2
pm2 start server.js //Yor main node server.js
pm2 stop server //no need of giving .js , .js only required at start of process
pm2 restart server //for any changes are done to restart
For more You can follow digital ocean tutorials for more details from below link
Digital_Ocean_Link

Nodejs with forever issue in VPS, forever command not found

I am new to NodeJS. I tried using my node js application in my local machine, with installing forever module, script runs continuously
But when I deploy my application in VPS(Godaddy). Node application runs fine. I tried installing forever inorder to run my script continuously, with command
npm install forever -g.
It installs the module but when trying to run it with command
forever start app.js
says forever command not found.
Can anyone guide me what am I doing wrong? Any help will be appreciated.
You should check with npm list -g if the module is listed.
Other way to check it is to go to a bash console and type ls /usr/local/lib/node_modules | grep forever and check if the module is there.
If it's not there, something went wrong installing the module. Install it again with sudo npm install -g forever.
Check with printenv | egrep -o "(.*node*) in the bash console and see if you have "NODE_PATH=/opt/lib/node_modules".
If not export NODE_PATH=/opt/lib/node_modules int the console and try again the forever command forever start app.js.

Deploying Ghost - How to define the root path of an application that is managed with NPM forever?

I installed Ghost Blog with a subdomain (http://blog.example.com) on Ubuntu 14.04 LTS behind Apache 2.4.7 as a Proxy.
Ghost is located in var/www/html/ghost and can be started temporarily with sudo npm start, which works fine.
However, when I want to permanently deploy Ghost using NPM forever, which I installed globally following the official Ghost guide, I get the following error message:
info: Forever processing file: index.js
error: Cannot start forever
error: script /home/myuser/index.js does not exist.
Simply copying index.js to the predefined npm forever root location does not solve the problem, as the Ghost application is not located there. I also tried sudo NODE_ENV=production forever start var/www/html/ghost/index.js without success.
I always get a 503 Error - Service Unavailable.
How do I tell NPM forever to look for the file in var/www/html/ghost/index.js?
It sounds like you are not giving forever the correct file. That is what this error is saying (error: script /home/myuser/index.js does not exist.). There is no index.js in your /home/myuser directory.
So, to start Ghost with forever first cd to the ghost directory:
cd /var/www/html/ghost
and then do the forever start:
sudo NODE_ENV=production forever start index.js
Should be good to go once you do that

Resources