title: How to rebuild native npm modules for Electron?
body: <p>Please help me to understand how to rebuild the native npm modules for Electron 1.6.2?</p>
  <p>I used steps from <a href="https://electron.atom.io/docs/tutorial/quick-start" rel="nofollow noreferrer">https://electron.atom.io/docs/tutorial/quick-start</a> to create a simple Electron application.<br />
  Then I installed ref package and loaded it in main.js.<br />
  ref package - it is the native package. I have to rebuild this package to have ability to use it in the Electron application.</p>
  <p>I used following tutorial to rebuild the native package - <a href="https://github.com/electron/electron/blob/master/docs/tutorial/using-native-node-modules.md" rel="nofollow noreferrer">https://github.com/electron/electron/blob/master/docs/tutorial/using-native-node-modules.md</a></p>
  <p>There are 3 approaches how to rebuild the native npm packages:</p>
  <p><strong>1) &quot;Installing modules and rebuilding for Electron using electron-rebuild&quot;:</strong><br />
  I installed <code>electron-rebuild</code> npm package.<br />
  Then, according to tutorial, I need just to run following command:</p>
  <pre><code>.\node_modules\.bin\electron-rebuild.cmd  
  </code></pre>
  <p>But electron-rebuild tried to download <a href="https://atom.io/download/electron/v1.6.2/iojs-v1.6.2.tar.gz" rel="nofollow noreferrer">https://atom.io/download/electron/v1.6.2/iojs-v1.6.2.tar.gz</a><br />
  Why it downloaded something from <a href="https://atom.io/download/electron" rel="nofollow noreferrer">https://atom.io/download/electron</a> if Electron release files are located here - <a href="https://github.com/electron/electron/releases" rel="nofollow noreferrer">https://github.com/electron/electron/releases</a>?<br />
  Electron 1.6.2 was released only few weeks ago, but iojs-v1.6.2.tar.gz was released in Mar 2015.<br />
  Do I understand correctly that electron-rebuild downloads the wrong files?</p>
  <p><strong>2) Manually building packages for Electron using node-gyp.</strong></p>
  <pre><code>set HOME=%USERPROFILE%/.electron-gyp  
  cd ./node_modules/ref  
  node-gyp rebuild --target=1.6.2 --arch=x64 --dist-url=https://atom.io/download/electron  
  </code></pre>
  <p>And here again dist-url uses <a href="https://atom.io/download/electron" rel="nofollow noreferrer">https://atom.io/download/electron</a>.<br />
  Why?<br />
  I tried do not use <code>--dist-url</code>.<br />
  But in this case node-gyp downloads following files:</p>
  <pre><code>gyp http GET https://iojs.org/download/release/v1.6.2/iojs-v1.6.2.tar.gz  
  gyp http 200 https://iojs.org/download/release/v1.6.2/iojs-v1.6.2.tar.gz  
  gyp http GET https://iojs.org/download/release/v1.6.2/SHASUMS256.txt  
  gyp http GET https://iojs.org/download/release/v1.6.2/win-x64/iojs.lib  
  gyp http GET https://iojs.org/download/release/v1.6.2/win-x86/iojs.lib  
  gyp http 200 https://iojs.org/download/release/v1.6.2/SHASUMS256.txt  
  gyp http 200 https://iojs.org/download/release/v1.6.2/win-x64/iojs.lib  
  gyp http 200 https://iojs.org/download/release/v1.6.2/win-x86/iojs.lib 
  </code></pre>
  <p>Is it correct?</p>
  <p><strong>3) Rebuild native packages using npm:</strong></p>
  <pre><code>rem # Electron's version.  
  set npm_config_target=1.6.2  
  rem # The architecture of Electron, can be ia32 or x64.  
  set npm_config_arch=x64  
  set npm_config_target_arch=x64  
  rem # Download headers for Electron.  
  rem set npm_config_disturl=https://atom.io/download/electron  
  rem # Tell node-pre-gyp that we are building for Electron.  
  set npm_config_runtime=electron  
  rem # Tell node-pre-gyp to build module from source code.  
  set npm_config_build_from_source=true  
  rem # Install all dependencies, and store cache to ~/.electron-gyp.  
  set HOME=%USERPROFILE\.electron-gyp  
  npm install  
  </code></pre>
  <p>Again <a href="https://atom.io/download/electron" rel="nofollow noreferrer">https://atom.io/download/electron</a>.<br />
  Why?</p>
  <p>Does anyone know how to rebuild ref native package for Electron 1.6.2 correctly?</p>