Last active
December 18, 2015 04:59
-
-
Save geoom/5729251 to your computer and use it in GitHub Desktop.
basic commands for using nodejs (tested in debian)
This file contains 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
/* ----------------------------------------- | |
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