EN
npm - create package.json file
9 points
In this short article, we would like to show how to create package.json
file with npm
.
Quick solution (run in the command line in the project directory):
xxxxxxxxxx
1
npm init
Note: the command carries user through the steps setting basic configuration.
To run npm init
we should create some directory for our new project.
xxxxxxxxxx
1
$ mkdir test-project
2
3
$ cd test-project
4
5
$ npm init
6
7
This utility will walk you through creating a package.json file.
8
It only covers the most common items, and tries to guess sensible defaults.
9
10
See `npm help init` for definitive documentation on these fields
11
and exactly what they do.
12
13
Use `npm install <pkg>` afterwards to install a package and
14
save it as a dependency in the package.json file.
15
16
Press ^C at any time to quit.
17
package name: (test-project)
18
version: (1.0.0)
19
description:
20
entry point: (index.js)
21
test command:
22
git repository:
23
keywords:
24
author:
25
license: (ISC)
26
About to write to /home/john/Desktop/test-project/package.json:
27
28
{
29
"name": "test-project",
30
"version": "1.0.0",
31
"description": "",
32
"main": "index.js",
33
"scripts": {
34
"test": "echo \"Error: no test specified\" && exit 1"
35
},
36
"author": "",
37
"license": "ISC"
38
}
39
40
41
Is this OK? (yes)
Result:
xxxxxxxxxx
1
$ ls -al
2
total 12
3
drwxrwxr-x 2 john john 4096 lut 22 12:32 .
4
drwxr-xr-x 8 john john 4096 lut 22 12:31 ..
5
-rw-rw-r-- 1 john john 205 lut 22 12:32 package.json