@@ -49,9 +49,9 @@ For completeness there is also `--type=commonjs`, for explicitly running a `.js`
4949file as CommonJS. This is the default behavior if ` --type ` or ` -m ` is
5050unspecified.
5151
52- The ` --type=module ` or ` -m ` flags can also be used to configure Node.js to treat as
53- an ES module input sent in via ` --eval ` or ` --print ` (or ` -e ` or ` -p ` ) or piped
54- to Node.js via ` STDIN ` .
52+ The ` --type=module ` or ` -m ` flags can also be used to configure Node.js to treat
53+ as an ES module input sent in via ` --eval ` or ` --print ` (or ` -e ` or ` -p ` ) or
54+ piped to Node.js via ` STDIN ` .
5555
5656``` sh
5757node --experimental-modules --type=module --eval \
@@ -151,8 +151,9 @@ package scope:
151151
152152## Package Entry Points
153153
154- When a ` package.json ` contains ` "type": "module" ` , its ` "main" ` field defines
155- the ES module entry point for the package.
154+ The ` package.json ` ` "main" ` field defines the entry point for a package,
155+ whether the package is included into CommonJS via ` require ` or into an ES
156+ module via ` import ` .
156157
157158<!-- eslint-skip -->
158159``` js
@@ -177,6 +178,9 @@ CommonJS.
177178As with ` import ` statements, for ES module usage the value of ` "main" ` must be
178179a full path including extension: ` "./index.mjs" ` , not ` "./index" ` .
179180
181+ If the ` package.json ` ` "type" ` field is omitted, a ` .js ` file in ` "main" ` will
182+ be interpreted as CommonJS.
183+
180184> Currently a package can define _ either_ a CommonJS entry point ** or** an ES
181185> module entry point; there is no way to specify separate entry points for
182186> CommonJS and ES module usage. This means that a package entry point can be
0 commit comments