From e64b5e95f6f904ace6b36dcfc6e3cd8f27d276a5 Mon Sep 17 00:00:00 2001 From: ficristo Date: Sat, 20 May 2017 10:35:56 +0200 Subject: [PATCH] On Windows force a 32 bit build until nodejs 64 bit is supported --- src/extensibility/node/npm-installer.js | 15 +++------------ src/extensibility/node/package-validator.js | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/extensibility/node/npm-installer.js b/src/extensibility/node/npm-installer.js index 46d25cfbeb6..c85495b4b15 100644 --- a/src/extensibility/node/npm-installer.js +++ b/src/extensibility/node/npm-installer.js @@ -37,22 +37,13 @@ var Errors = { * Private function to run "npm install --production" command in the extension directory. * * @param {string} installDirectory Directory to remove + * @param {array} npmOptions can contain additional options like `--production` or `--proxy http://127.0.0.1:8888` * @param {function} callback NodeJS style callback to call after finish */ function _performNpmInstall(installDirectory, npmOptions, callback) { var npmPath = path.resolve(path.dirname(require.resolve("npm")), "..", "bin", "npm-cli.js"); - var args = [npmPath, "install"]; - - // npmOptions can contain additional args like { "production": true, "proxy": "http://127.0.0.1:8888" } - Object.keys(npmOptions).forEach(function (key) { - var value = npmOptions[key]; - if (value === true) { - args.push("--" + key); - } else if (typeof value === "string" && value.length > 0) { - args.push("--" + key, value); - } - }); - + var args = [npmPath, "install"].concat(npmOptions); + console.log("running npm " + args.slice(1).join(" ") + " in " + installDirectory); var child = spawn(process.execPath, args, { cwd: installDirectory }); diff --git a/src/extensibility/node/package-validator.js b/src/extensibility/node/package-validator.js index 64483351b26..ceee52883c6 100644 --- a/src/extensibility/node/package-validator.js +++ b/src/extensibility/node/package-validator.js @@ -295,10 +295,20 @@ function extractAndValidateFiles(zipPath, extractDir, options, callback) { errors.push([Errors.MISSING_MAIN, zipPath, mainJS]); } - performNpmInstallIfRequired({ - production: true, - proxy: options.proxy - }, { + var npmOptions = ['--production']; + + if (options.proxy) { + npmOptions.push('--proxy ' + options.proxy); + } + + if (process.platform.startsWith('win')) { + // On Windows force a 32 bit build until nodejs 64 bit is supported. + npmOptions.push('--arch=ia32'); + npmOptions.push('--npm_config_arch=ia32'); + npmOptions.push('--npm_config_target_arch=ia32'); + } + + performNpmInstallIfRequired(npmOptions, { errors: errors, metadata: metadata, commonPrefix: commonPrefix,