title: nodejs ReferenceError: require is not defined
body: <p>I'm executing a project with node src/main.js from MacOS.
  Node version 14.5.0
  I get on the first line</p>
  <pre><code>const express = require('express')
  ReferenceError: require is not defined
  At ModuleJob.run (internal/modules/esm/module_job.ks:140:23)
  at asyns Loader.import (internal/modules/esm/loader.js:162.24)
  </code></pre>
  <p>The strange thing is that if I run the same project( i.e. the same folder from another Mac with same node version), it works fine.</p>
  <p>What could that be?
  What could I do?
  I tried npm i again, deleted node_modules....out of ideas</p>
  <p>package.json</p>
  <pre><code> {
    &quot;type&quot;: &quot;module&quot;,
    &quot;dependencies&quot;: {
    &quot;body-parser&quot;: &quot;^1.19.0&quot;,
    &quot;express&quot;: &quot;^4.17.1&quot;,
    &quot;mongodb&quot;: &quot;^3.5.9&quot;
   },
   &quot;devDependencies&quot;: { &quot;nodemon&quot;: &quot;^2.0.4&quot;}
   }
  </code></pre>
  <p>PS. on this particular Mac I had to uninstall/reinstall node a couple of time, swearing a lot. It could be that I have a bad install? if so what can I fix?</p>