Last active
October 7, 2019 16:41
-
-
Save servercharlie/9a7e0d0e1645b4c6fbfe5de566fcf1ca to your computer and use it in GitHub Desktop.
Setting up NodeJS w/ NPM + PM2 on Ubuntu 16.10 (Yakkety Yak!)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> SSH Login to your home directory. | |
> Get APT updates & upgrades. | |
sudo apt-get update | |
sudo apt-get upgrade | |
> NodeJS & NPM | |
> https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions | |
> Installs the latest NodeJS & NPM, including the essential build tools (used by most packages). | |
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - | |
sudo apt-get install -y nodejs | |
sudo apt-get install -y build-essential | |
> Done. | |
> NPM Permissions Tweaks | |
> @ https://docs.npmjs.com/getting-started/fixing-npm-permissions#option-2-change-npms-default-directory-to-another-directory | |
> Prevents some fuck-ups. | |
mkdir ~/.npm-global | |
npm config set prefix '~/.npm-global' | |
export PATH=~/.npm-global/bin:$PATH | |
source ~/.profile | |
> Done. | |
> NPM Global Packages Tweaks | |
> Prevents more fuck-ups w/ globally-installed packages. | |
npm get prefix | |
> Copy the output you get from 'npm get prefix' | |
sudo nano ~/.profile | |
> scroll down, find PATH, append :ThePrefixYouGotAbove/bin | |
> ie: if 'npm get prefix' gives me '/home/YourUser/.npm-global' | |
> and my PATH is... PATH="$HOME/bin:$HOME/.local/bin:$PATH" | |
> it should become: PATH="$HOME/bin:$HOME/.local/bin:$PATH:/home/YourUser/.npm-global/bin" | |
> CTRL + X + Y (saves it) | |
source ~/.profile | |
> Done. | |
> Install PM2 (Optional) | |
npm install pm2 -g | |
> Should run smoothly if you followed all of the above steps. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
THanks !! it works