title: Node - require('crypto') resolves to { }
body: <p>I'm using NPM for dependency management and Angular5 with TypeScript. </p>
  
  <p><strong>EDIT</strong> I haven't installed the crypto package from npm, I am referencing the node inbuilt package.</p>
  
  <p>No matter what I do, the "crypto" package resolves as an empty object. 
  I have installed the node @typings package and can see the definition for @typings definition crypto in the node_modules/@typings folder.</p>
  
  <p>What I've tried:</p>
  
  <p><code>import * as cryp from 'crypto'</code></p>
  
  <p><code>declare var crypto:any</code></p>
  
  <p><code>declare module crypto</code></p>
  
  <p><code>var cryp = require('crypto')</code></p>
  
  <p>I tried deleting the modules folder and reinstalling. </p>
  
  <p>I tried updating everything to the most recent version.</p>
  
  <p>I tried creating a new project and only using crypto with no additional dependencies. No luck.</p>
  
  <p>The biggest issue here is we are trying to use libraries which depend on this 'crypto' module and they do not function without it. </p>
  
  <p>What's most confusing about this is it doesn't throw any errors, and it's not coming as undefined, but an empty object. It doesn't work in the project or outside of it. And other Node JS/TS modules are working fine, it's literally (so far) just 'crypto' which is having this issue. Any guidance or thoughts here would be great.</p>
  
  <p>Primarily using ng serve to run the application but tried packaging and running using node directly as well.</p>
  
  <p>Per @kendor 's suggestion, I ran a tsc --traceResolution. This is the part regarding crypto. Interestingly it says "node_modules" does not exist, but it clearly does, and other packages are resolving from it correctly.</p>
  
  <pre><code>======== Resolving module 'crypto' from '[...]/src/app/app.component.ts'. ========
  Explicitly specified module resolution kind: 'NodeJs'.
  Loading module 'crypto' from 'node_modules' folder, target file type 'TypeScript'.
  Directory '[...]/src/app/node_modules' does not exist, skipping all lookups in it.
  Directory '[...]/src/node_modules' does not exist, skipping all lookups in it.
  File '[...]/node_modules/crypto.ts' does not exist.
  File '[...]/node_modules/crypto.tsx' does not exist.
  File '[...]/node_modules/crypto.d.ts' does not exist.
  File '[...]/node_modules/@types/crypto.d.ts' does not exist.
  Directory '[...]/node_modules' does not exist, skipping all lookups in it.
  Directory '[...]node_modules' does not exist, skipping all lookups in it.
  Directory '/home/node_modules' does not exist, skipping all lookups in it.
  Directory '/node_modules' does not exist, skipping all lookups in it.
  Loading module 'crypto' from 'node_modules' folder, target file type 'JavaScript'.
  Directory '[...]/src/app/node_modules' does not exist, skipping all lookups in it.
  Directory '[...]/src/node_modules' does not exist, skipping all lookups in it.
  File '[...]/node_modules/crypto.js' does not exist.
  File '[...]/node_modules/crypto.jsx' does not exist.
  Directory '[...]/node_modules' does not exist, skipping all lookups in it.
  Directory '[...]node_modules' does not exist, skipping all lookups in it.
  Directory '/home/node_modules' does not exist, skipping all lookups in it.
  Directory '/node_modules' does not exist, skipping all lookups in it.
  ======== Module name 'crypto' was not resolved. ========
  </code></pre>