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
Authors can tell Node.js to interpret JavaScript as an ES module via the .mjs file extension, the package.json "type" field with a value "module", or the --input-type flag with a value of "module". These are explicit markers of code being intended to run as an ES module.
次の3つの方法でコードをESMとして解釈するように伝えることができる。
.mjs拡張子を使う
package.jsonに"type": "module"と記載する
--input-typeフラグを使用する
When code lacks explicit markers for either module system, Node.js will inspect the source code of a module to look for ES module syntax. If such syntax is found, Node.js will run the code as an ES module; otherwise it will run the module as CommonJS. See Determining module system for more details.
明示していない場合はESMのみの構文があれば、ESMとして解釈する。
changed the title [-]ESMのコードとして解釈させるために`.mjs`拡張子を使うのではなく、`package.json`に`"type": "module"`と書くように変更する[/-][+]コードをESMとして解釈させるために`.mjs`拡張子を使うのではなく、`package.json`に`"type": "module"`と書くように変更する[/+]on Feb 15, 2026
Activity
[-]ESMのコードとして解釈させるために`.mjs`拡張子を使うのではなく、`package.json`に`"type": "module"`と書くように変更する[/-][+]コードをESMとして解釈させるために`.mjs`拡張子を使うのではなく、`package.json`に`"type": "module"`と書くように変更する[/+]chvmvd commentedon Feb 15, 2026
対応事項
npm initコマンドを実行した際に、typeと尋ねられた時にmoduleを指定することを説明するutcode-learn/docs/3-web-servers/04-module/index.mdx
Line 149 in 27d5138
.mjsと記載されているところを修正する