title: node.js 13 - import is not working properly
body: <p>$ node --version
  v13.8.0</p>
  <p>Let's create three files:</p>
  <pre><code>// package.json
  {
    &quot;type&quot;: &quot;module&quot;
  }
  
  // foobar.js 
  function foo() { console.log('foo') }
  export default {foo}
  
  // index.js 
  import Foo from './foobar.js';
  Foo.foo();
  </code></pre>
  <p>Run index.js</p>
  <pre><code>$ node index.js
  (node:22768) ExperimentalWarning: The ESM module loader is experimental.
  foo
  </code></pre>
  <p>All working.</p>
  <p>And now changing './foobar.js'; to './foobar';</p>
  <pre><code>// index.js 
  import Foo from './foobar';
  Foo.foo();
  </code></pre>
  <p>And we get an error!</p>
  <pre><code>(node:22946) ExperimentalWarning: The ESM module loader is experimental.
  internal/modules/esm/resolve.js:58
    let url = moduleWrapResolve(specifier, parentURL);
              ^
  Error: Cannot find module /foobar imported from /index.js
  </code></pre>
  <p>There is no other files in directory.</p>
  <p>Why does it happens?
  Why import without extension doesn't work?</p>
  <p>UPDATE:
  <a href="https://nodejs.org/api/esm.html" rel="nofollow noreferrer">https://nodejs.org/api/esm.html</a></p>
  <blockquote>
  <p>package.json &quot;type&quot; field</p>
  <p>Files ending with .js or <strong>lacking any extension</strong> will be loaded as ES  modules when the nearest parent package.json file contains a top-level field &quot;type&quot; with a value of &quot;module&quot;.</p>
  </blockquote>
  <p>So './foobar' must work.</p>
  <p>UPDATE 2:</p>
  <blockquote>
  <p>I believe what the documentation call &quot;extensionless files&quot; are literaly files without extensions, not files imported without extensions.</p>
  <p>For example, if you import your file with import Foo from './foobar';, and you file is called foobar without the .js extension, it will work fine.</p>
  </blockquote>
  <p>Thanks to @Seblor</p>