To use JavaScript / ECMAScript modules (ES modules, since ES6) with iisnode you have to create a new entry point file.



Now just set the server.cjs instead of app.js in the web.config.


      enableXFF="true" />

    <httpErrors existingResponse="PassThrough" />

      <add name="iisnode" path="server.cjs" verb="*" modules="iisnode" />

        <rule name="NodeApp">
          <match url=".*" />
          <action type="Rewrite" url="server.cjs" />


That's it! Your node app will now use the ES modules system.

What is the .cjs and .mjs file extension?

  • .cjs - uses the node's origin CommonJS module system
  • .mjs - uses ES module
  • .js - by default same as .cjs

In the package.json we can change the default module system to ES modules.
.js file extensions will then be treated the same as .mjs files.

// package.json
  "type": "module", // default value is "commonjs"
  "name": "my-app",