You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: TUTORIAL.md
+22-179
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,8 @@
1
1
# Learn NPM package json
2
2
3
-
> The Node Package Manager (NPM) is a command-line tool used by developers to share and control modules (or packages) of JavaScript code written for use with Node.js.
4
-
5
-
```config
6
-
config:
7
-
testRunner:
8
-
command: npm run programmatic-test
9
-
path: coderoad
10
-
actions:
11
-
commits:
12
-
- '55a9b6d'
13
-
- 'd58d630'
14
-
commands:
15
-
- npm install
16
-
repo:
17
-
uri: https://github.com/coderoad/fcc-learn-npm
18
-
branch: v0.3.0
19
-
dependencies:
20
-
- name: node
21
-
version: >=10
22
-
```
3
+
The Node Package Manager (NPM) is a command-line tool used by developers to share and control modules (or packages) of JavaScript code written for use with Node.js.
23
4
24
-
## Intro
5
+
## L1 Intro
25
6
26
7
> Introduction to the package.json
27
8
@@ -37,7 +18,7 @@ Most developers prefer to install packages local to each project to create a sep
37
18
The `package.json` file is the center of any Node.js project or NPM package. It stores information about your project, similar to how the <head> section of an HTML document describes the content of a webpage. It consists of a single JSON object where information is stored in key-value pairs. There are only two required fields; "name" and "version", but it’s good practice to provide additional information about your project that could be useful to future users or maintainers.
38
19
If you look at the file tree of your project, you will find the package.json file on the top level of the tree. This is the file that you will be improving in the next couple of challenges.
39
20
40
-
## Author
21
+
## L2 Author
41
22
42
23
> Package.json author
43
24
@@ -47,27 +28,12 @@ One of the most common pieces of information in this file is the `author` field.
47
28
"author": "Jane Doe",
48
29
```
49
30
50
-
### Step 1
51
-
52
-
```config
53
-
setup:
54
-
files:
55
-
- package.json
56
-
commits:
57
-
- '5326ec8'
58
-
commands:
59
-
- npm install
60
-
solution:
61
-
files:
62
-
- package.json
63
-
commits:
64
-
- '424cf66'
65
-
```
31
+
### L2S1
66
32
67
33
Add your name as the `author` of the project in the package.json file.
68
34
**Note:** Remember that you’re writing JSON, so all field names must use double-quotes (") and be separated with a comma (,).
69
35
70
-
## Description
36
+
## L3 Description
71
37
72
38
> Package.json description
73
39
@@ -82,26 +48,13 @@ Here's an example:
82
48
"description": "A project that does something awesome",
83
49
```
84
50
85
-
### Step 1
86
-
87
-
```config
88
-
setup:
89
-
files:
90
-
- package.json
91
-
commits:
92
-
- '68ddb97'
93
-
solution:
94
-
files:
95
-
- package.json
96
-
commits:
97
-
- '138ad0e'
98
-
```
51
+
### L3S1
99
52
100
53
Add a `description` to the package.json file of your project.
101
54
102
55
**Note:** Remember to use double-quotes for field-names (") and commas (,) to separate fields.
103
56
104
-
## Keywords
57
+
## L4 Keywords
105
58
106
59
> Package.json keywords
107
60
@@ -115,26 +68,13 @@ Here's an example:
115
68
116
69
As you can see, this field is structured as an array of double-quoted strings.
117
70
118
-
### Step 1
119
-
120
-
```config
121
-
setup:
122
-
files:
123
-
- package.json
124
-
commits:
125
-
- '2069439'
126
-
solution:
127
-
files:
128
-
- package.json
129
-
commits:
130
-
- 'f2ed460'
131
-
```
71
+
### L4S1
132
72
133
73
Add an array of suitable strings to the `keywords` field in the package.json file of your project.
134
74
135
75
One of the keywords should be "freecodecamp".
136
76
137
-
## License
77
+
## L5 License
138
78
139
79
> Package.json license
140
80
@@ -146,24 +86,11 @@ Some common licenses for open source projects include MIT and BSD. License infor
146
86
"license": "MIT",
147
87
```
148
88
149
-
### Step 1
150
-
151
-
```config
152
-
setup:
153
-
files:
154
-
- package.json
155
-
commits:
156
-
- 'f2229d1'
157
-
solution:
158
-
files:
159
-
- package.json
160
-
commits:
161
-
- '9378267'
162
-
```
89
+
### L5S1
163
90
164
91
Fill the `license` field in the package.json file of your project as you find suitable.
165
92
166
-
## Version
93
+
## L6 Version
167
94
168
95
> Package.json version
169
96
@@ -173,24 +100,11 @@ A `version` is one of the required fields of your package.json file. This field
173
100
"version": "1.2.0",
174
101
```
175
102
176
-
### Step 1
177
-
178
-
```config
179
-
setup:
180
-
files:
181
-
- package.json
182
-
commits:
183
-
- '60a4e7b'
184
-
solution:
185
-
files:
186
-
- package.json
187
-
commits:
188
-
- 'f9f7f29'
189
-
```
103
+
### L6S1
190
104
191
105
Add a `version` to the package.json file of your project.
192
106
193
-
## External Packages
107
+
## L7 External Packages
194
108
195
109
> Installing dependencies from NPM
196
110
@@ -215,29 +129,13 @@ npm install express
215
129
216
130
Installed packages are created in a `node_modules` folder in your project. Avoid editing or changing the node_modules folder or its contents.
217
131
218
-
### Step 1
219
-
220
-
```config
221
-
setup:
222
-
files:
223
-
- package.json
224
-
commits:
225
-
- 'e97c095'
226
-
watchers:
227
-
- package.json
228
-
- node_modules/moment
229
-
solution:
230
-
files:
231
-
- package.json
232
-
commits:
233
-
- '97af83a'
234
-
```
132
+
### L7S1
235
133
236
134
Install the "moment" package to the `dependencies` field of your package.json file by running the command line npm install.
237
135
238
136
**Note:** Moment is a handy library for working with time and dates.
239
137
240
-
## Semantic Versioning
138
+
## L8 Semantic Versioning
241
139
242
140
> Versioning packages
243
141
@@ -262,27 +160,11 @@ Using the NPM cli, a specific version of a package can be installed by specifyin
262
160
npm install express@4.17.0
263
161
```
264
162
265
-
### Step 1
266
-
267
-
```config
268
-
setup:
269
-
files:
270
-
- package.json
271
-
commits:
272
-
- 'be03933'
273
-
watchers:
274
-
- package.json
275
-
- node_modules/moment
276
-
solution:
277
-
files:
278
-
- package.json
279
-
commits:
280
-
- 'ba77ae7'
281
-
```
163
+
### L8S1
282
164
283
165
In the dependencies section of your package.json file, change the `version` of moment to match MAJOR version 2, MINOR version 10 and PATCH version 2
284
166
285
-
## Receive Patch Updates
167
+
## L9 Receive Patch Updates
286
168
287
169
> Using `~` to recieve patches
288
170
@@ -294,27 +176,14 @@ To allow an npm dependency to update to the latest PATCH version, you can prefix
294
176
"package": "~1.3.8"
295
177
```
296
178
297
-
### Step 1
298
-
299
-
```config
300
-
setup:
301
-
files:
302
-
- package.json
303
-
commits:
304
-
- 'c4ff0f6'
305
-
solution:
306
-
files:
307
-
- package.json
308
-
commits:
309
-
- 'cc1f2a5'
310
-
```
179
+
### L9S1
311
180
312
181
In the package.json file, your current rule for how npm may upgrade moment is to use a specific version (2.10.2). But now, you want to allow the latest 2.10.x version.
313
182
Use the tilde (`~`) character to prefix the version of moment in your dependencies, and allow npm to update it to any new PATCH release.
314
183
315
184
**Note:** The version numbers themselves should not be changed.
316
185
317
-
## Receive Minor Updates
186
+
## L10 Receive Minor Updates
318
187
319
188
> Using `^` to receive minor updates
320
189
@@ -328,26 +197,13 @@ Your current version of moment should be "~2.10.2" which allows npm to install t
328
197
329
198
This would allow updates to any 1.x.x version of the package.
330
199
331
-
### Step 1
332
-
333
-
```config
334
-
setup:
335
-
files:
336
-
- package.json
337
-
commits:
338
-
- 'fb75ecf'
339
-
solution:
340
-
files:
341
-
- package.json
342
-
commits:
343
-
- 'd0e1a22'
344
-
```
200
+
### L10S1
345
201
346
202
Use the caret (`^`) to prefix the version of moment in your dependencies and allow npm to update it to any new MINOR release.
347
203
348
204
**Note:** The version numbers themselves should not be changed.
349
205
350
-
## Remove a Dependency
206
+
## L11 Remove a Dependency
351
207
352
208
> Removing a dependency
353
209
@@ -357,20 +213,7 @@ But what if you want to remove an external package that you no longer need? You
357
213
358
214
This same method applies to removing other fields in your package.json as well.
0 commit comments