I have reactjs project that need to be run on the linux server. Whenever I run the app on server using "sudo npm run lin_stage_server" it seems to be working fine on 80 port.
when I tried to run app through pm2 with command "sudo pm2 start npm -- lin_stage_server" its not working for me.
In addition to the above command i also tried
"sudo pm2 start npm -- BRANCH_ENV=stage NODE_ENV=production PORT=80 node appserverstart.js
"
Please help !
----- Error details ------
Error details
----- Package.json -----
Package.json
----- appserverstart.js -----
appserverstart.js
-------Additional info-------
server: CentOS Linux version 7 core,
npm version: 6.4.1,
pm2 version: 3.5.1,
node version: 8.11.1,
You are not passing run to npm:
pm2 start npm -- run lin_stage_server
pm2 start npm -- lin_stage_server is effectively npm lin_stage_server.
pm2 start npm -- run lin_stage_server is effectively npm run lin_stage_server
Related
I have been trying to install nodemon for my application by using the command:
npm install nodemon -g
And the following is the output I have received:
changed 116 packages, and audited 117 packages in 8s
16 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
However, when I run nodemon -v, it is showing error. Can someone help?
Below are some solutions
This is how you can install nodemon
npm install -g nodemon
after that you have to run this command: npm run dev
here dev is (script) server name
after that if you are facing error like
" 'nodemon' is not recognized as an internal or external command,
operable program or batch file. "
Then after install nodemon globally write below command:
npm config get prefix
in output you will get PATH and then past this path in to the Environment Variables and it solved
Restart the terminal and run this command
nodemon run dev
On Heroku I'm trying to release a pushed image as described here: https://stackoverflow.com/a/50788844/2771889
docker build --file Dockerfile.prod --tag registry.heroku.com/my-app/web .
heroku container:login
docker push registry.heroku.com/my-app/web
heroku container:release web
My heroku.yml looks like this (used when I deploy from GitHub, and works fine):
build:
docker:
web: Dockerfile.prod
release:
image: web
command:
- yarn typeorm migration:run && yarn console seed
run:
web: yarn start:prod
It seems that the run command is not taken into account. When running container:release the logs show:
Starting process with command node
Whereas during a release from GitHub I'd see the correct command:
Starting process with command /bin/sh -c yarn start:prod
The release command however is recognized and executed correctly.
How can I make sure container:release runs the container with the correct command?
I had to add a CMD to my Dockerfile:
# ...
CMD yarn start:prod
This doesn't break GitHub deployments with heroku.yml.
I am getting an error while running my server file using nodemon. When I type the command nodemon, I get the following output.
[~/D/g/sendMail-lib|3.6.5]
‹master*› »»»» nodemon 0|15:35:32
[nodemon] 1.17.5
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
[nodemon] Internal watch failed: ENOSPC: no space left on device, watch '/home/abdus/Documents/github/sendMail-lib/3808.txt'
[~/D/g/sendMail-lib|3.6.5]
‹master*› »»»»
Additionally, it creates almost 4000 blank text files(1.txt, 2.txt and so on).
I tried this commands but the problem still persists.
I am on Arch Linux with Node version 10.5.0, NPM version 6.1.0 and Nodemon version 1.17.5.
Just ask me if you need any more information.
I had the same problem.
Run nodemon as sudo.
$ sudo nodemon
Or
# nodemon
Most issues I run into with Arch are solved by just running as root. ;)
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Taken from here.
This is effectively a rights problem, but you don't need to use sudo, just give the user that run nodemon the rights to write to the build directory
an exemple with permissive rights (we use nodemon, so I assume we are in dev)
sudo chmod a+rwX my-application-dir
I installed nodemon locally so, I created an "npm start" script and run it as root
like so: sudo npm start
I got this error when trying to run npm start with a start script that looked like this:
"start": "nodemon server.js"
It seems that I had a global installation of nodemon, but not a local version in my project's node_modules. Once I ran npm install nodemon, it installed it locally and worked without requiring root permissions.
nodemon: v1.18.5
OS: ubuntu 18.04
I'm going to run react-boilerplate application forever in the server.
I found forever and I'm not sure how I pass parameters to forever. The command to run server is like following:
PORT=80 npm run start:production
Seems like forever start PORT=80 npm run start:production doesn't help me.
One thing is that PORT=80 part is setting the env variable, this kind of command should be in front of other commands. The other thing is that to run npm scripts with forever, you need to use different syntax, so PORT=80 forever start -c "npm run start:production" /path/to/app/dir/.
If you're running forever form the project folder, the path should be ./
Or you can run a react application with pm2 or with nohup
1) install pm2 globally
npm install pm2 -g
2) navigate to the project folder and execute, space is required after --
pm2 start npm -- start
3) to see running instances
pm2 ps
4) to see the other options
pm2 --help
To run with nohup
1) navigate to the project folder
nohup bash -c 'npm start' &
pm2 is superb production process manager for Node. In addition to starting and daemonizing any application, it has a built in load balancer.
Install pm2:
npm install pm2 -g
To add start and add deamon to your app, navigate to the app folder and:
pm2 start app.js
To make pm2 autoboot on server restart:
$ pm2 startup
Then copy and paste the code generated.
For this you will need:
Install forever usingnpm install -g forever
Run the forever command PORT=<YOUR PORT> forever start -c "<command>" ./
Your command can be for example npm start and npm run dev.
Use ./ only if you are in the project folder.
Port means your port number, usually 80 or 443.
I cloned a repo here https://github.com/willianjusten/bootstrap-boilerplate and do the following step.
git clone git://github.com/willianjusten/bootstrap-boilerplate.git new_project
cd bootstrap-boilerplate
npm install
gulp
The gulp does the work. But is the server started? In gulp js file I'm seeing the author use livereload, how do I start my development with that?
You can use nodemon (https://github.com/remy/nodemon). If any file is changed, nodemon will re-start automatically.
Sample usage
install
npm install -g nodemon
start node
nodemon server.js