Forever start angular-http-server is not working - node.js

I'm trying to run angular dist in the background and I'm targeting the node_modules folder in the dist correctly and finding the angular-http-server library there.
The terminal is not showing any error but it's not starting. I'm using this command:
forever start angular-http-server --host 'IP'
Is the command wrong? What should I do?

You may use it like this:
forever start node_modules/#angular/cli/bin/ng serve --host {ip_address or domain} --prod
Change the ip_address or domain to the desired one

with the command
forever start node_modules/#angular/cli/bin/ng serve --host {ip_address or domain} --prod
Show me an error:
error: Cannot start forever error: script /home/ec2-user/angular01/backend-java-angular01/node_modules/#angular/cli/bin/node_modules/#angular/cli/bin/ng does not exist.
Thanks for the help
PD: ng its working fine.
forever is installed
folder #angular/cli/bin/ng exits

Related

Cannot connect to my databse addon on heroku

I attempted to use the command Heroku pg:psql to connect to my database addon in heroku but got a response below
--> Connecting to postgresql-regular-61345
unrecognized win32 error code: 123could not find a "psql" to execute
unrecognized win32 error code: 123could not find a "psql" to execute
psql: fatal: could not find own program executable
! psql exited with code 1
After using the heroku logs --tail command i got the following errors
sh: 1: nodemon: not found
Process exited with status 127
State changed from starting to crashed
I can also see all processes stopping with SIGTERM and the process exiting with status 143
Resolution steps I have taken
Verified that the environment variables have the path for installed postgress14 on my PC
Added a procfile to the root file in my backend code and spcified "web: node matthewfaceappback/server.js in the file"
Changed my set port to a variable port using process.env.PORT || 3000
Set all environment variable including my database url(set by default) on config variable in heroku
Verified there is a start up script
Updated all my packages using "npm update". after doing this i started expereincing the issue of processes stopping with SIGTERM and the process exiting with status 143
I moved nodemon from devDependencies to dependencies. nodemon version is 2.0.15
In package.json i inputed an engines parameter using the version of node in my case
{"engines": {
"node": "14.17.4"
}}
I restarted heroku using "heroku restart"
Below are links to the screenshots of the error
https://www.dropbox.com/s/5bdbyi9e99lbxhu/pic1.PNG?dl=0
https://www.dropbox.com/s/41euniaes5q68c9/pic2.PNG?dl=0
https://www.dropbox.com/s/50oqzbwmwrqogax/pic3.PNG?dl=0
Put nodemon back in the devDependencies and add it as a second node script in package.json:
"scripts": {
"start": "node matthewfaceappback/server.js",
"dev": "nodemon matthewfaceappback/server.js"
},
These two errors are completely unrelated.
The database connection error
The first issue, which I believe is the one you actually care about at the moment based on the title of the question, indicates that the Heroku CLI can't find a PostgreSQL client on your local machine.
The documentation makes the following recommendation
Set up Postgres on Windows
Install Postgres on Windows by using the Windows installer.
Remember to update your PATH environment variable to add the bin directory of your Postgres installation. The directory is similar to: C:\Program Files\PostgreSQL\<VERSION>\bin. Commands like heroku pg:psql depend on the PATH and do not work if the PATH is incorrect.
If you haven't already installed Postgres locally, do so. (This is a good idea anyway as you should be developing locally and you'll probably need a database.)
Then make sure to add its bin/ directory to your PATH environment variable.
The Nodemon error
The second issue is because you are trying to use nodemon in production. Heroku strips development dependencies out of Node.js applications after building them, which normally makes sense. Nodemon is a development tool, not something that should be used for production hosting.
Depending on the contents of your package.json, this might be as simple as changing your start script from nodemon some-script.js to node some-script.js. Alternatively, you can add a Procfile with the command you actually want to run on Heroku:
web: node some-script.js
See also Need help deploying a RESTful API created with MongoDB Atlas and Express

Is it possible to have Heroku Local run like nodemon?

I'm new to Heroku, a little bit less to NodeJS (and Nodemon).
I am now using heroku local to run my app in local (and be as close as possible to my prod environment) but I'd like to have my app rebuilt and restarted everytime I make a change in local (as with Nodemon for example).
Is there nay way to do this with heroku local?
Thanks!
Nicolas.
Old question, I know, but came up while I was searching for the same. There is an answer here: https://stackoverflow.com/a/46561121
This is what I have in my package.json:
"scripts": {
"start": "nodemon --exec 'heroku local' --signal SIGTERM"
}
For anybody coming across this post in search of a solution. As mentioned by nicolasdaudin in response to tom, you can add nodemon to the heroku Procfile (https://devcenter.heroku.com/articles/procfile):
web: nodemon index.js
Note that nodemon must be installed globally for this to work:
npm i -g nodemon
Then you should be able to run heroku locally as normal with nodemon watching for changes:
heroku local web

Start server node.js with forever on ubuntu

I been searching alot and no result with same problem as me.
I have a Node.js application and I want to start it with forever start app.js, the process starts but no website found when i try in browser. The process is in the list when I write forever list.
Npm start works fine but I cant use nodejs/node app.js or my_file.js.. It gives no error or something just new command line with no output in terminal.
So anyone know why I cant start the app with nodejs app.js or forever start app.js .. No files works.
Thanks!
In express 4 you should write :
forever ./bin/www
And if you check your package.json file you can see :
"scripts": {
"start": "node ./bin/www"
}
It's the npm start script
Alternatively, you can try using PM2.
It does a great job at keeping your app alive, and has some really useful features such as load balancing, no downtime, and a web interface to monitor your processes.
In addition, I find it dead simple to use.

Forever-npm will not start my ExpressJS app

I am trying to use forever so that I can assure that my ExpressJS app will remain running constantly.
I am using Ubuntu 14.04 LTS.
Strangely, 'forever list' displays nothing, 'forever --version' displays nothing
I've tried:
forever start -c "npm start" ./
and:
forever start app.js
Without anything displayed.
If you are using node js with express framework then script will not start using :
forever start app.js
First stop all running apps:
forever stopall
When this Express framework used it must be started with:
forever start ./bin/www
and you should find this in package.json file:
"scripts": {
"start": "node ./bin/www"
}
I hope it helps you.

nodejs + nodemon + forever give me an error

I just installed forever globally (-g). Before that I used to run with
$ npm start
Now after installed forever, I tried to lunch the node app
$ NODE_ENV=development forever nodemon server.js
but I receive this error
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
error: Cannot start forever
error: script /path/to/app/nodemon does not exist.
the same also with
$ NODE_ENV=development forever nodemon server.js
any idea?
The error you received in your output:
error: script /path/to/app/nodemon does not exist.
It appears that forever is looking for nodemon in the current working directory, and can't find it because it doesn't exist there. Try providing the absolute path when starting nodemon, which can be found with which nodemon.
forever start /usr/local/bin/nodemon server.js
Note that the start flag is what puts the application in daemon mode.
Try this
NODE_ENV=development forever start -c nodemon server.js
The -c is for execute commands, forever send you that error because it's looking for a app called nodeamon, but your app is server.js

Resources