NodeJS Installation guide
- NVM
- Installation
- Usagee
- NPM
- Installation
- Proxy setup
- YARN
- Installation
- Add repository
- Install with apt-get
- Usage
- Starting a new project
- Adding a dependency
- Adding a dependency to a specific category
- Upgrading a dependency
- Removing a dependency
- Installing all the dependencies of a project
- Global action on a package
- Force Yarn to use https on github repositories
Installation
1
| curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash
|
Restart the terminal.
Usagee
1
2
3
4
5
6
7
| nvm install node # Install the latest version of node
nvm install 4.2.2 # Install v4.2.2 of node
nvm use node # Use latest version of node
nvm exec 4.2 node --version # Subshell command
|
Installation
1
2
3
| which node # Get node's path.
cd .nvm/versions/node/v8.5.0/lib/ # Navigate to the above path
npm install npm # Install NPM
|
Proxy setup
1
2
| npm config set proxy http://user:pwd@host:port
npm config set https-proxy http://user:pwd@host:port
|
Installation
Add repository
1
2
3
4
| curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
> OK
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
> deb https://dl.yarnpkg.com/debian/ stable main
|
Install with apt-get
1
2
| apt-get update
apt-get install yarn
|
Usage
Starting a new project
Adding a dependency
1
2
3
| yarn add [package]
yarn add [package]@[version]
yarn add [package]@[tag]
|
Adding a dependency to a specific category
1
2
3
| yarn add [package] --dev
yarn add [package] --peer
yarn add [package] --optional
|
Upgrading a dependency
1
2
3
| yarn upgrade [package]
yarn upgrade [package]@[version]
yarn upgrade [package]@[tag]
|
Removing a dependency
Installing all the dependencies of a project
Global action on a package
1
| yarn global <ACTION> [package]
|
Global packages are installed in yarn global bin
location.
That location may be added to the PATH environment variable.
Force Yarn to use https on github repositories
1
2
3
4
5
| # Fails
yarn add @angular/cli
# Works
yarn add git+https://github.com/angular/angular-cli
|
Graphic logo for Node.js software from nodejs.org/en/about/resources/