How to create Node js project
npm init is the command to create a node project.
1 |
npm init |
npm init is a tool for creating (or modifying) a project’s package.json file.
When you enter the command npm init on your terminal, it will take you through a series of questions, for which, you can either go with default answers or can give different answers.
This is how it looks like in my terminal, after running npm init command.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
D:\trials\nodejs\training>npm init This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sensible defaults. See `npm help json` for definitive documentation on these fields and exactly what they do. Use `npm install <pkg> --save` afterwards to install a package and save it as a dependency in the package.json file. Press ^C at any time to quit. name: (training) Node JS Training Excercises Sorry, name can only contain URL-friendly characters and name can no longer cont ain capital letters. name: (training) node js training excercises Sorry, name can only contain URL-friendly characters. name: (training) node-js-training-excercises version: (1.0.0) description: Training Excercises for Node Js entry point: (index.js) test command: git repository: keywords: node js, training author: Jacob Nelson license: (ISC) About to write to D:\trials\nodejs\training\package.json: |
And, here is the preview of package.json got created, after completing above process.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
{ "name": "node-js-training-excercises", "version": "1.0.0", "description": "Training Excercises for Node Js", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ "node", "js", "training" ], "author": "Jacob Nelson", "license": "ISC" } |
Once you created package.json, first step of creating node project is over.
Leave a Reply