Advertisement

nodejs

Reding Book

  • Node.js Recipes - Cory Gackenheimer

npm

  • update npm version
>sudo npm update -g npm

npm init

  • use npm init wizard for generate package.json
>mkdir node_test
>npm init

nvm

install nvm

  • manual install
git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`
    • you need to source it from your shell, I always add this line to my ~/.bashrc
 . ~/.nvm/nvm.sh
  • shell install
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.26.1/install.sh | bash
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.26.1/install.sh | bash

sudo nvm

  • For CentOS 6
  • add nvm.sh to current user .bashrc
vi ~/.bashrc
## add below
. /home/appdev/.nvm/nvm.sh
  • add nvm.sh to root .basrc
vi /root/.bashrc
## add below
. /home/appdev/.nvm/nvm.sh
  • sudo visudo
## add
Defaults    secure_path = + /usr/local/nodejs/nodejs/bin:/usr/local/bin
  • edit current user ~/.bash_profile
vi ~/.bash_profile
#add
PATH=$PATH:/usr/local/nodejs/nodejs/bin:$HOME/bin
alias sudo='sudo env PATH=$PATH:$NVM_BIN'

nvm help

  • nvm usage
nvm help

nvm list-remote , nvm list

  • list all node version available for download
nvm ls-remote
  • list local version
nvm ls

= nvm common command

  • install version
nvm install 4.1.0
nvm uninstall 4.1.0
nvm alias dev 4.1.0
nvm unalias dev
nvm run 4.1.0 app.js
nvm run dev app.js
nvm use 4.1.0

nvm default alias

nvm alias default 0.12.7

package.json

Community content is available under CC-BY-SA unless otherwise noted.