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
description: Syntax detection is enabled by default.
129
+
-->
130
+
131
+
> Stability: 1.2 - Release candidate
132
+
133
+
Node.js will inspect the source code of ambiguous input to determine whether it
134
+
contains ES module syntax; if such syntax is detected, the input will be treated
135
+
as an ES module.
136
+
137
+
Ambiguous input is defined as:
138
+
139
+
* Files with a `.js` extension or no extension; and either no controlling
140
+
`package.json` file or one that lacks a `type` field; and
141
+
`--experimental-default-type` is not specified.
142
+
* String input (`--eval` or STDIN) when neither `--input-type` nor
143
+
`--experimental-default-type` are specified.
144
+
145
+
ES module syntax is defined as syntax that would throw when evaluated as
146
+
CommonJS. This includes the following:
147
+
148
+
*`import` statements (but _not_`import()` expressions, which are valid in
149
+
CommonJS).
150
+
*`export` statements.
151
+
*`import.meta` references.
152
+
*`await` at the top level of a module.
153
+
* Lexical redeclarations of the CommonJS wrapper variables (`require`, `module`,
154
+
`exports`, `__dirname`, `__filename`).
155
+
118
156
### Modules loaders
119
157
120
158
Node.js has two systems for resolving a specifier and loading modules.
@@ -1369,6 +1407,7 @@ This field defines [subpath imports][] for the current package.
1369
1407
[ES modules]: esm.md
1370
1408
[Node.js documentation for this section]: https://github.com/nodejs/node/blob/HEAD/doc/api/packages.md#conditions-definitions
0 commit comments