title: 'require() of ES modules is not supported. ' error with Node.js, express, swagger-jsdoc
body: <p>I trying to import swagger-jsdoc but I get an error. I searched on internet but other solutions not work for me.</p>
  <p>My server.js file like that:</p>
  <pre><code>const express = require('express');
  const app = express();
  const swaggerJsDoc = require('swagger-jsdoc');
  
  const port = 3000;
  
  app.get('/customers', (req,res) =&gt; {
      res.send('Customers Route');
  })
  
  app.listen(port, ()=&gt; {
      console.log('Server listening on 3000');
  })
  </code></pre>
  <p>And my package.json file like that:</p>
  <pre><code>{
    &quot;name&quot;: &quot;swaggertest&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;index.js&quot;,
    &quot;scripts&quot;: {
      &quot;start&quot;: &quot;nodemon app.js&quot;,
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;
    },
    &quot;keywords&quot;: [],
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;dependencies&quot;: {
      &quot;express&quot;: &quot;^4.17.1&quot;,
      &quot;nodemon&quot;: &quot;^2.0.7&quot;,
      &quot;swagger-jsdoc&quot;: &quot;^7.0.0-rc.4&quot;,
      &quot;swagger-ui-express&quot;: &quot;^4.1.6&quot;
    }
  }
  </code></pre>
  <p>But when I try to run this project with &quot;npm start&quot; I getting this error:</p>
  <p>node:internal/modules/cjs/loader:1108
  throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
  ^</p>
  <blockquote>
  <p>Error [ERR_REQUIRE_ESM]: Must use import to load ES Module:
  /Users/me/Desktop/Projects/swaggertest/node_modules/swagger-jsdoc/index.js
  require() of ES modules is not supported. require() of
  /Users/me/Desktop/Projects/swaggertest/node_modules/swagger-jsdoc/index.js
  from /Users/me/Desktop/Projects/swaggertest/app.js is an ES module
  file as it is a .js file whose nearest parent package.json contains
  &quot;type&quot;: &quot;module&quot; which defines all .js files in that package scope as
  ES modules. Instead rename index.js to end in .cjs, change the
  requiring code to use import(), or remove &quot;type&quot;: &quot;module&quot; from
  /Users/me/Desktop/Projects/swaggertest/node_modules/swagger-jsdoc/package.json.
  ...
  code: 'ERR_REQUIRE_ESM'
  ...</p>
  </blockquote>
  <p>How can I solve this issue?</p>