Tag: node.js

  • Install Yarn Package Manager

    Install Yarn Package Manager

    Yarn is a package manager for JavaScript like npm. It is commonly used for managing dependencies for Node.js applications, but it can also be used for front-end development with frameworks like Rmeact, Angular, and Vue.js.

    To install the Yarn package manager on ubuntu, run:

    curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
    echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
    sudo apt-get update && sudo apt-get install yarn
    

    Back to Node.js

  • Installing nvm (Node.js Version Manager)

    nvm is a node version manager, which allows you to run multiple versions of node.js

    To install nvm, run

    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

    To list all available node versions, run

    nvm ls-remote
    

    To install a particular node.js version, run

    nvm install 8.9.4

    To activate/select a node.js version, use

    nvm use 8.9.4

    nodejs

  • pm2 process manager for node.js

    Auto Start pm2 on boot
    How to host static site using pm2

    pm2 is a process manager for node.js applications. It is similar to forever.

    http://pm2.keymetrics.io

    First you need to install npm, on Ubuntu/Debian, run

    apt install npm

    To install pm2, run

    npm install pm2 -g

    Start an Application

    pm2 start app.js

    Start an Application with name

    pm2 start app.js -n "app-name-here"

    Start npm

    pm2 start npm --name my-app -- run start

    Start the Application in Cluster mode with

    pm2 start app.js -n "app-name-here" -i 5

    To Scale a clustered application, run

    pm2 scale app-name-here 2

    Start the processes on reboot

    pm2 save
    pm2 startup

    List running applications

    pm2 ls

    Controlling running application

    pm2 stop    
    pm2 restart 
    pm2 delete

    Restart all running applications

    pm2 restart all

    nodejs