diff --git a/tools/run_tests/build_node.bat b/tools/run_tests/build_node.bat
index 6896bc1d1bb1480ea66c222390b9a5104168d367..3ddd0e73cf77d4895852e8fc689574321a137ded 100644
--- a/tools/run_tests/build_node.bat
+++ b/tools/run_tests/build_node.bat
@@ -27,4 +27,12 @@
 @rem (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 @rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-npm install --build-from-source
\ No newline at end of file
+call npm install --build-from-source
+
+@rem delete the redundant openssl headers
+for /f "delims=v" %%v in ('node --version') do (
+  rmdir "%HOMEDRIVE%%HOMEPATH%\.node-gyp\%%v\include\node\openssl" /S /Q
+)
+
+@rem rebuild, because it probably failed the first time
+call npm install --build-from-source
\ No newline at end of file
diff --git a/tools/run_tests/pre_build_node.bat b/tools/run_tests/pre_build_node.bat
index 6e7cbe5d420d58060f8c26dbc9b5953f92e9ee1c..ffb4a09f15ae83a32b9f8adb0e32610120a1b4a1 100644
--- a/tools/run_tests/pre_build_node.bat
+++ b/tools/run_tests/pre_build_node.bat
@@ -28,12 +28,5 @@
 @rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 @rem Expire cache after 1 week
-npm update --cache-min 604800
+call npm update --cache-min 604800
 
-npm install node-gyp-install
-.\node_modules\.bin\node-gyp-install.cmd
-
-@rem delete the redundant openssl headers
-for /f "delims=v" %%v in ('node --version') do (
-  rmdir "%HOMEDRIVE%%HOMEPATH%\.node-gyp\%%v\include\node\openssl" /S /Q
-)
\ No newline at end of file