Skip to content

Instantly share code, notes, and snippets.

@geoom
Last active December 18, 2015 04:59
Show Gist options
  • Save geoom/5729251 to your computer and use it in GitHub Desktop.
Save geoom/5729251 to your computer and use it in GitHub Desktop.
basic commands for using nodejs (tested in debian)
/* -----------------------------------------
Install node.js and npm in Debian
----------------------------------------- */
*firts way (recommended):
sudo apt-get install python-software-properties python g++ make
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
*second way:
sudo apt-get update
sudo apt-get install git-core curl build-essential openssl libssl-dev
git clone https://github.com/joyent/node.git
cd node
./configure
make
sudo make install
node -v
sudo apt-get install npm
/* -----------------------------------------
Usign node to run
----------------------------------------- */
node app.js // simple waw of to run
/* -----------------------------------------
Usign npm
----------------------------------------- */
npm install <package-name> // install the package named <package-name> in local
npm install -g <package-name> // install the package named <package-name> in global (valid for all projects)
npm install // install all depedencies found in packages.json
npm start // to run using npm, this requieres packages.json with setting start
npm list -g // show the global dependencies list on npm
npm remove -g <package-name> // uninstall a package named <package-name> in global
/* -----------------------------------------
Usign express
----------------------------------------- */
npm install express // install express in local way
npm install express -g // install express in global way
express myproject // create a new project named 'myproject' using express (npm install -g express)
/* -----------------------------------------
Usign nodemon
----------------------------------------- */
nodemon app.js // to save automaticly changes in files (monitor) using nodemon (npm install -g nodemon)
/* -----------------------------------------
Usign nvm (https://github.com/creationix/nvm/blob/master/README.markdown)
----------------------------------------- */
git clone https://github.com/creationix/nvm.git ~/.nvm // install NVM
source ~/.nvm/nvm.sh // to activate nvm
nvm install <version_to_install> // install a specify Node version
nvm use <version_to_install> // switch or use a specify Node version
nvm deactivate // deactivate NVM
nvm alias default <version_to_install> // to set a default Node version to be used in any new shell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment