title: Node.js - SyntaxError: Unexpected token '{'
body: <p>I am trying to use ES6 syntax. My code is like this,</p>
  <pre><code>if(process.env.NODE_ENV === 'production') {
      import { googleClientID,googleClientSecret,mongoURI,cookieKey  } from './prod';
  } else {
      import { googleClientID,googleClientSecret,mongoURI,cookieKey  } from './dev';
  }
  
  export { googleClientID,googleClientSecret,mongoURI,cookieKey  }
  </code></pre>
  <p>This is showing the following error.</p>
  <pre><code>[0] [nodemon] restarting due to changes...
  [0] [nodemon] starting `node index.js`
  [0] file:///C:/Projects/emaily/config/keys.js:2
  [0]     import { googleClientID,googleClientSecret,mongoURI,cookieKey  } from './prod';
  [0]            ^
  [0]
  [0] SyntaxError: Unexpected token '{'
  [0]     at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18)
  </code></pre>
  <p>I am following the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import" rel="nofollow noreferrer">documentation</a>. My syntax seems ok. What is the reason for an error like this?</p>
  <p>I also tried <code>import * as keys from './prod';</code>. This gives me <code>SyntaxError: Unexpected token '*'</code></p>
  <p>My node version is 14.15.4. I am using <code>&quot;type&quot;: &quot;module&quot;,</code> in package.json.</p>