title: Error: Cannot find module 'nexmo' & error TS2307: Cannot find module nexmo
body: <p>so I'm working with the <strong>NestJs</strong> Framework and <strong>typescript</strong>.</p>
  <p>I was asked to add two factor authentication (SMS) using the node library of <strong>Nexmo</strong>.
  Here is a link from their website: <a href="https://dashboard.nexmo.com/getting-started/verify" rel="nofollow noreferrer">https://dashboard.nexmo.com/getting-started/verify</a></p>
  <p>Everything worked as promised while in development mode.</p>
  <p>But when I tried to build for production I got this error:</p>
  <pre><code>Error: Cannot find module 'nexmo'
  </code></pre>
  <p>So I started googling about it.</p>
  <p>I first read about <strong>import vs require</strong>.</p>
  <p>Almost everything in my NestJs project works with import.</p>
  <p>But I remember using require sometimes with no problem.
  For example when I had to use these two I had no problem:</p>
  <pre><code>const axios = require('axios');
  const xml2js = require('xml2js');
  </code></pre>
  <p>Then I came across people that were having similar problems and they were able to solve them by modifying a bit their tsconfig.json.</p>
  <p>Some added the <strong>&quot;moduleResolution&quot;: &quot;node&quot;</strong> instead of <strong>&quot;moduleResolution&quot;: &quot;classic&quot;</strong> while others changed the <strong>&quot;module&quot;: &quot;commonjs&quot;</strong> to <strong>&quot;module&quot;: &quot;AMD&quot;</strong>, or <strong>&quot;module&quot;: &quot;ESNext&quot;</strong></p>
  <p>I tried all of these with no avail. Sometimes the error was changing from:</p>
  <pre><code>Error: Cannot find module 'nexmo' 
  </code></pre>
  <p>to:</p>
  <pre><code>error TS2307: Cannot find module nexmo
  </code></pre>
  <p>Then I started reading here to understand more about this matter:
  <a href="https://www.typescriptlang.org/docs/handbook/module-resolution.html" rel="nofollow noreferrer">https://www.typescriptlang.org/docs/handbook/module-resolution.html</a></p>
  <p>Again I couldn't find my solution.</p>
  <p>A friend of mine told me to check something about installing <strong>typings</strong> but NestJs already uses <strong>@types</strong> which from what I read is a more updated version of typings.</p>
  <p>Other than that I had no luck.
  All I understand is that the project must be compiled to js from ts and that for some reason NestJs can't find the nexmo in the node_modules folder.</p>
  <p>Can you help or direct me to the right way?</p>