Node.js - How to Install & Basic Command
by C-an
DOWNLOAD
Go to : Intall Node.js and Download the lastest version. (Next > Next > … > Finish)
Basic Command
npm install [Module Name] -g
npm install [Module Name] --save
npm install
- -g means global. You use this option when you install something globally. [express-generator](#express-generator) or [nodemon](#nodemon) is an example of this option.
- --save You will need this when you install some module into the project you are currently working on. After applying this command, package.json file in your project will have the new module name and its version.
- You use npm install when you want to install the modules which is described in package.json at once. You can install easily if you have package.json.
Go to the directory you installed and type
npm install express-generator -g
npm install nodemon -g
Start Node.js
You can start node.js
with npm start
command.
type http://localhost:3000
and access it on web browser. And you can check if you connected to it or not.
If you want to close the program, you can use CTRL+C
. Then, it will close it.
Appendix
- express-generator is express templet creation module which can be used for all projects, not only for a sepecific project. You can install it with npm install express-generator -g
- nodemon opens node project automatically whenever something has been chanegd. You can install it with npm install nodemon -g
Subscribe via RSS