title: "npm install bcrypt" failing with "Error: Cannot find module 'nan'"
body: <p>I'm trying to get my existing Angular project working on a new laptop and getting it up and running is driving me crazy.  Here is what I have done:</p>
  
  <pre><code>git init 
  git clone &lt;project&gt;
  cd &lt;project directory&gt;
  delete package-lock.json
  npm install
  npm install --global --production windows-build-tools
  npm install bcrypt
  </code></pre>
  
  <p>The penultimate step is to ensure bcrypt dependencies are installed per <a href="https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions" rel="nofollow noreferrer">https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions</a> (caught me out previously).  But no matter what I try, I get the error listed at the end of this post. </p>
  
  <p>I have checked node_modules folder, and the 'nan' dependency does exist. even so, I tried installing it again (both locally and globally per <a href="https://stackoverflow.com/questions/9704660/node-error-cannot-find-module-already-installed">node error cannot find module already installed</a>) and it installs fine.  'nan' is also listed in the package.json file.</p>
  
  <p>I have tried:<br>
  * This: <a href="https://stackoverflow.com/questions/34464673/error-cannot-find-module-nan">Error: Cannot find module &#39;nan&#39;</a> <br>
  * Uninstalling node like this: <a href="https://stackoverflow.com/questions/20711240/how-to-completely-remove-node-js-from-windows">How to completely remove node.js from Windows</a>
  and also uninstalling all python installations I can find on the computer (including a v3 installation I thought might have been conflicting, but that doesn't seem to have been the problem).<br>
  * Other than that google is coming up blank.<br>
  * Taking a break and waiting for divine inspiration didn't work either.</p>
  
  <p>Here is the error:</p>
  
  <pre><code>node-pre-gyp WARN Using request for node-pre-gyp https download
  node-pre-gyp WARN Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.3/bcrypt_lib-v3.0.3-node-v64-win32-x64-unknown.tar.gz
  node-pre-gyp WARN Pre-built binaries not found for bcrypt@3.0.3 and node@10.15.0 (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
  internal/modules/cjs/loader.js:583
      throw err;
      ^
  
  Error: Cannot find module 'nan'
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
      at Function.Module._load (internal/modules/cjs/loader.js:507:25)
      at Module.require (internal/modules/cjs/loader.js:637:17)
      at require (internal/modules/cjs/helpers.js:22:18)
      at [eval]:1:1
      at Script.runInThisContext (vm.js:96:20)
      at Object.runInThisContext (vm.js:303:38)
      at Object.&lt;anonymous&gt; ([eval]-wrapper:6:22)
      at Module._compile (internal/modules/cjs/loader.js:689:30)
      at evalScript (internal/bootstrap/node.js:587:27)
  gyp: Call to 'node -e "require('nan')"' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
  gyp ERR! configure error
  gyp ERR! stack Error: `gyp` failed with exit code: 1
  gyp ERR! stack     at ChildProcess.onCpExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:345:16)
  gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
  gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
  gyp ERR! System Windows_NT 10.0.17134
  gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\project\\node_modules\\bcrypt\\lib\\binding\\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\\project\\node_modules\\bcrypt\\lib\\binding" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64" "--python=C:\\Users\\xxxxx\\.windows-build-tools\\python27\\python.exe"
  </code></pre>
  
  <h2>EDIT 1</h2>
  
  <p>The nan package is def installed. When I run <code>npm list nan</code>, I get:</p>
  
  <pre><code>aconcagua@0.0.0 C:\project
  +-- @angular-devkit/build-angular@0.8.9
  | `-- node-sass@4.11.0
  |   `-- nan@2.12.1  deduped
  +-- @angular/compiler-cli@6.1.10
  | `-- chokidar@1.7.0
  |   `-- UNMET OPTIONAL DEPENDENCY fsevents@1.2.6
  |     `-- nan@2.12.1  deduped
  `-- nan@2.12.1
  </code></pre>
  
  <p>I also tried <a href="https://stackoverflow.com/questions/12594541/npm-global-install-cannot-find-module">this</a> and added environment variables, with no luck.</p>