Thursday, November 1, 2018

centos putty node npm pm2


pm2 startup script

https://pm2.keymetrics.io/docs/usage/startup/
https://futurestud.io/tutorials/pm2-restart-processes-after-system-reboot


I think just run

pm2 startup
pm2 save
 
is good enough, no need to copy/run pm2 command, because did not tell you to do so.
 
so verytime update pm2 list, need run those 2 steps  





2020: update node pm2


node v11.15.0 is the latest version can work on godaddy centOS

latest stable version is v12.x.x will NOT work, error node: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by node)

because since you cannot install glibc package because of the lack of privileges the workaround would be to install and older version of node Also v8.16.2, v10.17.0 and v11.15.0 are available

 https://phoenixnap.com/kb/update-node-js-version

 https://stackoverflow.com/questions/57602008/error-while-installing-nodejs-on-godaddy-shared-linux-hosting



Update Node.js with NPM (Node Package Manager)

As an alternative, you can use Node’s official package manager to update Node.js. NPM is a tool for installing and managing package dependencies.
If you have Node on your system, you have NPM, as well. With the npm command, you can check running Node.js versions and install the latest release.
By adding the n module, you can interactively manage Node.js versions.
1. First, clear the npm cache:
npm cache clean -f
clear npm cache
2. Install n, Node’s version manager:
npm install -g n
install latest Node.js with npm n mmodule
3. With the n module installed, you can use it to:
  • Install the latest stable version: n stable
  • Install the latest release: n latest
  • Install a specific version: n [version.number]
  •  
  •  





======================================

linux

warning:
   1) logon putty, cd to directory, detele pm2 0
   2) close putty, must do this.Without 2), when you run 4), it still using your deleted old source-code folder.
 
   3) upload source code,extract.
   4) logon putty again, cd to directory, run node
 
 
 



run node------:------ must cd into directory,

sudo su - hoogw2000

cd /home/hoogw2000/public_html/arcgis_viewer/

Must rename .env to windows.env and centos.env to .env

pm2 start npm -- start



kill node:
http://pm2.keymetrics.io

pm2 delete 0

pm2 stop 0

pm2 list



windows start node js

nodemon --exec npm start

//  //    nohup nodemon --exec npm start


//  //    nohup nodemon --exec npm start






************* user (hoogw) cd /../.../ permission denied   ***********************


putty login (only as hoogw, it is server account) NOT hoogw2000, it is cpannel account,use to login to cpannel

whoami  [show currently what user]

ls, permission denied, try sudo ls

switch user to hoogw2000:
sudo su - hoogw2000

if get permission denied, try run as root(super user mode):
sudo su
        cd /.../......

if run as hoogw2000, you should be able to :
cd /home/hoogw2000/public_html/arcgis_viewer/
pm2 start npm -- start


========================================================

Install nodejs, npm, pm2 globally


Step 1 – Add Node.js Yum Repository
First of all, You need to enable node.js yum repository in your system provided by the Node.js official website. You also need development tools to build native add-ons to be installed on your system.

For Latest Release:-

yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_11.x | sudo -E bash -



For Stable Release:-

yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_8.x | sudo -E bash -


Step 2 – Install Node.js and NPM
After adding yum repository in your system lets install Node.js package. NPM will also be installed with node.js. This command will also install many other dependent packages on your system.

yum install nodejs
Don’t Miss => Yarn Installation ( A Node Modules Manager)

       Install Yarn using NPM
Yarn package is available to install with NPM. You can simply run the following command to install Yarn globally. Also, remove -g option to install for current project only.

sudo npm install yarn -g



Step 3 – Check Node.js and NPM Version
After installing node.js verify and check the installed version. You can find more details about current version on node.js official website.

node -v

v11.0.0
Also, check the version of npm.

npm -v

6.4.1




                  --------------------------
Install PM2 globally:

1)run as root(super user mode):   
  sudo su

2) npm i -g pm2


or if user is sudo-er

sudo npm i -g pm2
and then go back to user (or stay in root if it was created by root user) and run it:

pm2 start server.js



*******  End ****** user (hoogw) cd /../.../ permission denied   ***********************

No comments: