title: Warning: To load an ES module, set "type": "module" in the package.json or use the `.mjs` extension
body: <p>I'm developing a Discord bot to train myself with <code>Node.js</code> and <code>JavaScript</code>.
  I want to split each command into a file.</p>
  <p><strong>Index.js</strong></p>
  <pre class="lang-js prettyprint-override"><code>bot.on(&quot;message&quot;, (message) =&gt; {
      let args = message.content.split(&quot; &quot;); //splits the message into array 
      export {message, args} //export the variables that i need in other files
      switch (args[0]) {
          case &quot;?help&quot;:
          require(&quot;./commands/help/help.js&quot;)
          break 
      }
  });
  </code></pre>
  <p><strong>help.js</strong></p>
  <pre class="lang-js prettyprint-override"><code>import message from &quot;../../index.js&quot;
  
  console.log(&quot;[Command] ?help &quot; + message.author);
  message.channel.send( { embed: HelpEmbed });
  </code></pre>
  <p>The problem is that I get this error:</p>
  <pre><code>(node:4496) Warning: To load an ES module, set &quot;type&quot;: &quot;module&quot; in the package.json or use the `.mjs` extension.
  (Use `node --trace-warnings ...` to show where the warning was created)
  </code></pre>
  <p>or when I do not import a message another error says:</p>
  <pre><code>cannot read the propriety of undefined&quot; or &quot;message is undefined
  </code></pre>