Nodejs: Difference between revisions
Jump to navigation
Jump to search
(15 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
== Installation == | == Client Installation == | ||
=== Install Node === | === Install Node === | ||
* Web site link [http://nodejs.org] | * Node Web site link [http://nodejs.org] | ||
==== From Source ==== | |||
* Download Tar "node-v0.10.35.tar.gz" (version number may be different | * Download Tar "node-v0.10.35.tar.gz" (version number may be different | ||
* untar tar -zxvf node-v0.10.35.tar.gz | * untar tar -zxvf node-v0.10.35.tar.gz | ||
Line 9: | Line 11: | ||
* Run make : make | * Run make : make | ||
* Run make with install : sudo make install | * Run make with install : sudo make install | ||
==== From lastest PPA ==== | |||
* Get the last PPA information | |||
<pre> | |||
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - | |||
</pre> | |||
* Install node and requirement for buiding | |||
<pre> | |||
sudo apt-get install -y nodejs build-essential | |||
</pre> | |||
=== Install Express === | === Install Express === | ||
* sudo npm install -g express-generator | * sudo npm install -g express-generator | ||
=== Install NodeEclipse === | |||
==== Node Eclipse Client ==== | |||
<pre> | |||
npm install -g nodeclipse | |||
npm install -g express | |||
npm install -g express-generator | |||
npm install -g coffee-script | |||
</pre> | |||
==== Eclipse ==== | |||
==First App== | ==First App== | ||
Line 28: | Line 53: | ||
<pre>npm install</pre> | <pre>npm install</pre> | ||
===Stop Restart with nodemon | ===Stop Restart with nodemon=== | ||
<pre>nodemon</pre> | <pre>nodemon</pre> | ||
<pre>nodemon --debug</pre> | <pre>nodemon --debug</pre> | ||
===Error ENOSPC Increase number of file watches=== | |||
<pre>echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p</pre> | |||
== Database Driver Installation == | |||
<pre> | |||
cd /opt/oracle | |||
unzip instantclient-basic-linux.x64-12.1.0.2.0.zip | |||
unzip instantclient-sdk-linux.x64-12.1.0.2.0.zip | |||
mv instantclient_12_1 instantclient | |||
cd instantclient | |||
ln -s libclntsh.so.12.1 libclntsh.so | |||
export OCI_LIB_DIR=/opt/oracle/instantclient | |||
export OCI_INC_DIR=/opt/oracle/instantclient/sdk/include | |||
npm install oracledb | |||
</pre> | |||
== Server Installation == | |||
=== pm2 Installation === | |||
* Install pm2 application | |||
<pre>sudo npm install pm2 -g </pre> | |||
* Copy init Script | |||
<pre>pm2 startup ubuntu</pre> | |||
* Adjust init Script (if necessary) | |||
<pre> vi /etc/init.d/pm2-init.sh</pre> | |||
=== pm2 Main commandes === | |||
* Start application: from inside the application folder | |||
** Fork Mode | |||
<pre>pm2 start bin/www | |||
or pm2 start app.js</pre> | |||
**Cluster Mode | |||
<pre>pm2 start bin/www -i 0 | |||
or pm2 start app.js -i 0</pre> | |||
* List all runnng application | |||
<pre>pm2 save</pre> | |||
* Display detailed information of an application | |||
<pre>pm2 describe 0</pre> | |||
* Save current runnng application | |||
<pre>pm2 list</pre> | |||
* Stop application | |||
<pre>pm2 stop "id" </pre> | |||
* Remove application | |||
<pre>pm2 delete "id" </pre> | |||
* Start web interface port 9615 (localhost:9615) | |||
<pre>pm2 web</pre> | |||
* Stop pm2 (kill all | |||
<pre>pm2 kill</pre> | |||
== TroubleShoot == | |||
=== npm issues === | |||
* "User Root does not have permission to access the dev dir ..." | |||
<pre>sudo npm install --unsafe-perm </pre> |
Latest revision as of 20:57, 8 August 2022
Client Installation
Install Node
- Node Web site link [1]
From Source
- Download Tar "node-v0.10.35.tar.gz" (version number may be different
- untar tar -zxvf node-v0.10.35.tar.gz
- cd node-v0.10.35
- Run configure : ./configure
- Run make : make
- Run make with install : sudo make install
From lastest PPA
- Get the last PPA information
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
- Install node and requirement for buiding
sudo apt-get install -y nodejs build-essential
Install Express
- sudo npm install -g express-generator
Install NodeEclipse
Node Eclipse Client
npm install -g nodeclipse npm install -g express npm install -g express-generator npm install -g coffee-script
Eclipse
First App
- Create your app directory mkdir myapp
- Go into directory : cd myapp
- Run express : express
- Run npm : npm install
- test App : npm start
- try http://localhost:3000
Tricks
Update Version (package.json)
npm-check-updates -u
Update Dependencies
npm install
Stop Restart with nodemon
nodemon
nodemon --debug
Error ENOSPC Increase number of file watches
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Database Driver Installation
cd /opt/oracle unzip instantclient-basic-linux.x64-12.1.0.2.0.zip unzip instantclient-sdk-linux.x64-12.1.0.2.0.zip mv instantclient_12_1 instantclient cd instantclient ln -s libclntsh.so.12.1 libclntsh.so export OCI_LIB_DIR=/opt/oracle/instantclient export OCI_INC_DIR=/opt/oracle/instantclient/sdk/include npm install oracledb
Server Installation
pm2 Installation
- Install pm2 application
sudo npm install pm2 -g
- Copy init Script
pm2 startup ubuntu
- Adjust init Script (if necessary)
vi /etc/init.d/pm2-init.sh
pm2 Main commandes
- Start application: from inside the application folder
- Fork Mode
pm2 start bin/www or pm2 start app.js
- Cluster Mode
pm2 start bin/www -i 0 or pm2 start app.js -i 0
- List all runnng application
pm2 save
- Display detailed information of an application
pm2 describe 0
- Save current runnng application
pm2 list
- Stop application
pm2 stop "id"
- Remove application
pm2 delete "id"
- Start web interface port 9615 (localhost:9615)
pm2 web
- Stop pm2 (kill all
pm2 kill
TroubleShoot
npm issues
- "User Root does not have permission to access the dev dir ..."
sudo npm install --unsafe-perm