title: Express.js : express() not a function error
body: <p>I'm learning express and running the code from the terminal gives me errors, below are my code and the terminal error prompt</p>
  <pre><code>const express = require(&quot;express&quot;);
  const app = express();
  app.listen(3000);
  </code></pre>
  <p>Terminal said:</p>
  <pre><code>ReferenceError: require is not defined in ES module scope, you can use import instead
  This file is being treated as an ES module because it has a '.js' file extension and 'C:\Users\ENIOLA YUSUFF\desktop\my-express-server\package.json' contains &quot;type&quot;: &quot;module&quot;. To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
      at file:///C:/Users/ENIOLA%20YUSUFF/desktop/my-express-server/server.js:5:17    
  ←[90m    at ModuleJob.run (node:internal/modules/esm/module_job:197:25)←[39m        
      at async Promise.all (index 0)
  ←[90m    at async ESMLoader.import (node:internal/modules/esm/loader:337:24)←[39m   
  ←[90m    at async loadESM (node:internal/process/esm_loader:88:5)←[39m
  ←[90m    at async handleMainPromise (node:internal/modules/run_main:61:12)←[39m 
  </code></pre>
  <p>I tried using this code beneath instead thinking it was the difference in the node version but it solved half the problem.</p>
  <pre><code>import * as express from &quot;express&quot;;
  const app = express();
  app.listen(3000);
  </code></pre>
  <p>Terminal error:</p>
  <pre><code>$ node server.js
  file:///C:/Users/ENIOLA%20YUSUFF/desktop/my-express-server/server.js:2
  const app = express();
              ^
  
  TypeError: express is not a function
      at file:///C:/Users/ENIOLA%20YUSUFF/desktop/my-express-server/server.js:2:13    
      at ModuleJob.run (node:internal/modules/esm/module_job:197:25)
      at async Promise.all (index 0)
      at async ESMLoader.import (node:internal/modules/esm/loader:337:24)
      at async loadESM (node:internal/process/esm_loader:88:5)
      at async handleMainPromise (node:internal/modules/run_main:61:12)
  </code></pre>