title: "Error: Cannot find module '@app/foo'" in prod mode when using libs
body: <p>I have a project where I built several modules. After finding that nestjs has a lib cli command I ported all of them to use this style.
  Now my app can't find these modules when using <code>npm run start:prod</code>.</p>
  
  <pre><code>Error: Cannot find module '@app/foo'
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
      at Function.Module._load (internal/modules/cjs/loader.js:508:25)
      at Module.require (internal/modules/cjs/loader.js:637:17)
      at require (internal/modules/cjs/helpers.js:22:18)
      at Object.&lt;anonymous&gt; (/Users/xxx/Development/nest-test/dist/src/app.service.js:13:15)
      at Module._compile (internal/modules/cjs/loader.js:701:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
      at Module.load (internal/modules/cjs/loader.js:600:32)
      at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
      at Function.Module._load (internal/modules/cjs/loader.js:531:3)
  </code></pre>
  
  <p>I created a project with the basic code and one library to reproduce the problem: <a href="https://github.com/hkeio/nestjs-test" rel="nofollow noreferrer">https://github.com/hkeio/nestjs-test</a></p>
  
  <p>Even when I link the package node is not able to find the module.</p>
  
  <pre><code>cd libs/foo
  npm link
  cd ../..
  npm link @app/foo
  </code></pre>
  
  <p>When running <code>NODE_DEBUG=* npm run start:prod</code> I can see that he is looking at the right place but does not find the module:</p>
  
  <pre><code>MODULE 12494: looking for "@app/foo" in [
      "/Users/xxx/Development/nest-test/dist/src/node_modules",
      "/Users/xxx/Development/nest-test/dist/node_modules",
      "/Users/xxx/Development/nest-test/node_modules",
      "/Users/xxx/Development/node_modules",
      "/Users/xxx/node_modules",
      "/Users/node_modules",
      "/node_modules",
      "/Users/xxx/.node_modules",
      "/Users/xxx/.node_libraries",
      "/Users/xxx/.nvm/versions/node/v10.15.3/lib/node"
  ]
  
  ...
  
  $ pwd
  /Users/xxx/Development/nest-test/node_modules
  $ ll @app 
  total 0
  drwxr-xr-x    3 xxx  staff     96 May 30 09:04 .
  drwxr-xr-x  608 xxx  staff  19456 May 30 09:04 ..
  lrwxr-xr-x    1 xxx  staff     65 May 30 09:04 foo -&gt; ../../../../.nvm/versions/node/v10.15.3/lib/node_modules/@app/foo```
  </code></pre>