Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forever: command not found

I am getting a

forever: command not found error when I run a nodejs process using the forever command as a cronjob (in an amazon ec2 machine): the bash script I am using has the following code:

cd to/location/of/the/nodejs/file

forever start file.js

but I am able to run this file by using bash script.sh but I get the forever:command not found error when I run it via cronjob

I am confused dont know what could be the reason for this.

Has anybody else faced this problem?

Thanks in advance

like image 428
azero0 Avatar asked May 03 '14 14:05

azero0


People also ask

How do I fix NPM forever command not found error?

Use npx to solve the error "forever: command not found", e.g. npx forever start app.js or install the package globally by running npm install -g forever to be able to use the command without the npx prefix. The fastest way to solve the error is to use the npx command. Alternatively, you can install forever globally.

How to solve the “installing Forever failed” error?

The fastest way to solve the error is to use the npx command. Alternatively, you can install forever globally. If the global installation of forever fails, you might have to run the command prefixed with sudo.

Where will forever be installed on a Noden?

In this case foreverwill be installed in the actual install location of nodenot the location of the symbolic link. Share Improve this answer Follow answered May 30 '17 at 12:01 meesernmeesern

Why is forever not installed on my node path?

This is most likely not where you expect. This may be because nodein your path is a symbolic link. In this case foreverwill be installed in the actual install location of nodenot the location of the symbolic link. Share


2 Answers

Run this command: npm install forever -g

-g is to install it globally.

like image 98
sunitj Avatar answered Sep 19 '22 09:09

sunitj


For other users who face this problem:

you have to add the path of forever module and then run the script as a cronjob.

In linux the path normally is:

/usr/local/lib/node_modules/forever/bin/forever start file.js

just use this command in your script and the error forever:command not found will not bother you.

I know there must be some other fancy ways to do this but I am happy with this hack

like image 43
azero0 Avatar answered Sep 18 '22 09:09

azero0