title: Node Cannot Find Modules
body: <p>I am new to node and javascript and I'm trying to utilise the following library: <a href="https://github.com/Applifting/stv" rel="nofollow noreferrer">https://github.com/Applifting/stv</a></p>
  <p>I am unable to work out why I keep get the following &quot;Error: Cannot find module './stv'&quot;</p>
  <p>I've read several similar questions and responses but none of the suggested solutions, such as reinstalling node and npm, have helped.</p>
  <p>Below is the setup I went through to set up the package.json and install the stv module.</p>
  <pre><code>C:\votecount&gt;npm init -y
  Wrote to C:\votecount\package.json:
  
  {
    &quot;name&quot;: &quot;votecount&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;index.js&quot;,
    &quot;scripts&quot;: {
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;
    },
    &quot;keywords&quot;: [],
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;
  }
  
  C:\votecount&gt;npm add stv
  npm notice created a lockfile as package-lock.json. You should commit this file.
  npm WARN votecount@1.0.0 No description
  npm WARN votecount@1.0.0 No repository field.
  
  + stv@0.0.2
  added 1 package from 1 contributor and audited 1 package in 1.112s
  found 0 vulnerabilities
  </code></pre>
  <p>The package.json correctly shows stv under the dependencies.</p>
  <pre><code>  &quot;name&quot;: &quot;votecount&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;index.js&quot;,
    &quot;scripts&quot;: {
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;
    },
    &quot;keywords&quot;: [],
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,  
    &quot;dependencies&quot;: {
      &quot;stv&quot;: &quot;0.0.2&quot;
    },
  </code></pre>
  <p>I then created an index.js file containing:</p>
  <p><code>const stv = require('stv')</code></p>
  <p>Then when running index.js I get the following.</p>
  <pre><code>C:\votecount&gt;node index.js
  internal/modules/cjs/loader.js:968
    throw err;
    ^
  
  Error: Cannot find module './stv'
  Require stack:
  - C:\votecount\node_modules\stv\dist\index.js
  - C:\votecount\index.js
  ←[90m    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)←[39m
  ←[90m    at Function.Module._load (internal/modules/cjs/loader.js:841:27)←[39m
  ←[90m    at Module.require (internal/modules/cjs/loader.js:1025:19)←[39m
  ←[90m    at require (internal/modules/cjs/helpers.js:72:18)←[39m
      at Object.&lt;anonymous&gt; (C:\votecount\node_modules\←[4mstv←[24m\dist\index.js:3:13)
  ←[90m    at Module._compile (internal/modules/cjs/loader.js:1137:30)←[39m
  ←[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)←[39m
  ←[90m    at Module.load (internal/modules/cjs/loader.js:985:32)←[39m
  ←[90m    at Function.Module._load (internal/modules/cjs/loader.js:878:14)←[39m
  ←[90m    at Module.require (internal/modules/cjs/loader.js:1025:19)←[39m {
    code: ←[32m'MODULE_NOT_FOUND'←[39m,
    requireStack: [
      ←[32m'C:\\votecount\\node_modules\\stv\\dist\\index.js'←[39m,
      ←[32m'C:\\votecount\\index.js'←[39m
    ]
  }
  
  C:\votecount&gt;node -v
  v12.18.4
  
  C:\votecount&gt;npm -v
  6.14.6
  </code></pre>
  <p>However when I try this process installing the express module I don't have any problems and can import the module succesfully.</p>
  <pre><code>const express = require('express')
  const app = express();
  </code></pre>
  <p>As express seems to work fine I'm not sure how to go about troubleshooting this any further. I can see that part of the stv module I am trying to use has been written in typescript but the specific stv package.json seems to handle this.</p>
  <p>Any assistance with troubleshooting this error would be greatly appreciated.</p>
  <p><strong>Edit:</strong>
  I've also tried using <code>import { stv } from 'stv';</code> as per the git instructions but get another error:</p>
  <pre><code>C:\votecount&gt;node index.js
  (node:5432) Warning: To load an ES module, set &quot;type&quot;: &quot;module&quot; in the package.json or use the .mjs extension.
  C:\votecount\index.js:1
  import { stv } from 'stv';
  ^^^^^^
  
  SyntaxError: Cannot use import statement outside a module
  </code></pre>
  <p>If I then add &quot;type&quot;: &quot;module&quot; to the package.json in the root directory I then get:</p>
  <pre><code>C:\votecount&gt;node index.js
  (node:15736) ExperimentalWarning: The ESM module loader is experimental.
  file:///C:/votecount/index.js:1
  import { stv } from 'stv';
           ^^^
  SyntaxError: The requested module 'stv' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.
  For example:
  import pkg from 'stv';
  const { stv } = pkg;
  </code></pre>
  <p>Updating index.js to <code>import pkg from 'stv'; const { stv } = pkg;</code> then returns the original &quot;Error: Cannot find module './stv'&quot;</p>