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: session 3/chapters/1. Software Package Manager.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,3 +83,39 @@ NPX stands for Node Package Executor. It is a new addition to NPM version 5.2.0
83
83
There are more features that you can benefit from using NPX. Check this guide to learn more about NPX.
84
84
85
85
for more information, [read here](https://www.section.io/engineering-education/npm-vs-yarn-which-one-to-choose/)
86
+
87
+
# Metadata Inside package.json
88
+
89
+
## The name property
90
+
91
+
The `name property` in a `package.json` file is one of the fundamental components of the `package.json` structure. At its core, name is a string that is exactly what you would expect - the name of the module that the `package.json` is describing.
92
+
93
+
Inside your `package.json`, the `name property` as a string would look something like this:
94
+
95
+
## The main property
96
+
97
+
It's the main entry point to your node package (library) for npm. It's needed if your npm project becomes a node package (library) which can be installed via npm by others.
98
+
99
+
The `main property` of a `package.json` is a direction to the entry point to the module that the `package.json` is describing.
100
+
101
+
In a Node.js application, when the module is called via a require statement, the module's exports from the file named in the `main property` will be what's returned to the Node.js application.
102
+
103
+
Inside your `package.json`, the `main property`, with an entry point of `app.js`, would look like this:
When you have `'type': 'module'` in the package.json file, your source code should use import syntax. When you do not have, you should use require syntax.
114
+
115
+
- Adding `'type': 'commonjs'` to the package.json enables `commonjs` modules.
116
+
117
+

118
+
119
+
- Adding `'type': 'module'` to the package.json enables `ES6` modules.
0 commit comments