From 9cec98bb642d503b84c2885d556761441ac363d6 Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sat, 17 Oct 2020 09:09:35 +0200 Subject: [PATCH 1/6] Change rc-test to npm integration test --- package.json | 3 +- test/rc-test.js | 84 +++++++++++++++++++++++++++++++------------------ 2 files changed, 56 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index aee69ef..f7327fb 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "nock": "^10.0.6", "rimraf": "^2.5.2", "standard": "^13.0.2", - "tape": "^4.5.1" + "tape": "^4.5.1", + "tempy": "0.2.1" }, "bin": "./bin.js", "repository": { diff --git a/test/rc-test.js b/test/rc-test.js index 61f08db..cbb5de5 100644 --- a/test/rc-test.js +++ b/test/rc-test.js @@ -1,6 +1,8 @@ var test = require('tape') var path = require('path') var exec = require('child_process').exec +var fs = require('fs') +var tempy = require('tempy') // Locked to 0.2.1 for node 6 support test('custom config and aliases', function (t) { var args = [ @@ -41,19 +43,17 @@ test('custom config and aliases', function (t) { }) }) +// TODO: merge into above test test('npm args are passed on from npm environment into rc', function (t) { - var env = { - npm_config_argv: JSON.stringify({ - cooked: [ - '--build-from-source', - '--download', - 'https://foo.bar', - '--debug', - '--verbose' - ] - }) - } - runRc(t, '', env, function (rc) { + var args = [ + '--build-from-source', + '--download', + 'https://foo.bar', + '--debug', + '--verbose' + ].join(' ') + + runRc(t, args, {}, function (rc) { t.equal(rc['build-from-source'], true, '--build-from-source works') t.equal(rc.compile, true, 'compile should be true') t.equal(rc.debug, true, 'debug should be true') @@ -63,20 +63,28 @@ test('npm args are passed on from npm environment into rc', function (t) { }) }) +test('negative npm args are passed on from npm environment into rc', function (t) { + runRc(t, '--no-prebuild', {}, function (rc) { + t.equal(rc.prebuild, false, 'prebuild is false') + t.end() + }) +}) + test('npm_config_* are passed on from environment into rc', function (t) { var env = { - npm_config_proxy: 'PROXY', - npm_config_https_proxy: 'HTTPS_PROXY', - npm_config_local_address: 'LOCAL_ADDRESS', + // Note that these are validated by npm + npm_config_proxy: 'http://localhost/', + npm_config_https_proxy: 'https://localhost/', + npm_config_local_address: '127.0.0.1', npm_config_target: '1.4.0', npm_config_runtime: 'electron', npm_config_platform: 'PLATFORM', npm_config_build_from_source: 'true' } runRc(t, '', env, function (rc) { - t.equal(rc.proxy, 'PROXY', 'proxy is set') - t.equal(rc['https-proxy'], 'HTTPS_PROXY', 'https-proxy is set') - t.equal(rc['local-address'], 'LOCAL_ADDRESS', 'local-address is set') + t.equal(rc.proxy, 'http://localhost/', 'proxy is set') + t.equal(rc['https-proxy'], 'https://localhost/', 'https-proxy is set') + t.equal(rc['local-address'], '127.0.0.1', 'local-address is set') t.equal(rc.target, '1.4.0', 'target is set') t.equal(rc.runtime, 'electron', 'runtime is set') t.equal(rc.platform, 'PLATFORM', 'platform is set') @@ -116,18 +124,34 @@ test('using --tag-prefix will set the tag prefix', function (t) { }) function runRc (t, args, env, cb) { - var cmd = 'node ' + path.resolve(__dirname, '..', 'rc.js') + ' ' + args - env = Object.assign({}, process.env, env) - exec(cmd, { env: env }, function (err, stdout, stderr) { - t.error(err, 'no error') - t.equal(stderr.length, 0, 'no stderr') - var result - try { - result = JSON.parse(stdout.toString()) - t.pass('json parsed correctly') - } catch (e) { - t.fail(e.message) + var pkg = { + name: 'test', + private: true, + scripts: { + install: 'node ' + path.resolve(__dirname, '..', 'rc.js') + ' ' + args } - cb(result) + } + + var tmp = tempy.directory() + var json = JSON.stringify(pkg) + + fs.writeFile(path.join(tmp, 'package.json'), json, function (err) { + if (err) throw err + + var npm = process.platform === 'win32' ? 'npm.cmd' : 'npm' + var cmd = npm + ' run --silent install' + + exec(cmd, { env: env, cwd: tmp }, function (err, stdout, stderr) { + t.error(err, 'no error') + t.equal(stderr.toString().trim(), '', 'no stderr') + + try { + var result = JSON.parse(stdout.toString()) + } catch (e) { + return t.fail(e) + } + + cb(result) + }) }) } From 4ab06c6992ad2232ba598dbdeffa8cacd062a3cd Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sat, 17 Oct 2020 14:35:50 +0200 Subject: [PATCH 2/6] Test npm conditions that skip downloads --- test/rc-test.js | 5 +- test/skip-test.js | 104 +++++++++++++++++++++++++++++++++++++++++ test/util/clean-env.js | 14 ++++++ 3 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 test/skip-test.js create mode 100644 test/util/clean-env.js diff --git a/test/rc-test.js b/test/rc-test.js index cbb5de5..b80f0f6 100644 --- a/test/rc-test.js +++ b/test/rc-test.js @@ -3,6 +3,7 @@ var path = require('path') var exec = require('child_process').exec var fs = require('fs') var tempy = require('tempy') // Locked to 0.2.1 for node 6 support +var cleanEnv = require('./util/clean-env') test('custom config and aliases', function (t) { var args = [ @@ -141,7 +142,9 @@ function runRc (t, args, env, cb) { var npm = process.platform === 'win32' ? 'npm.cmd' : 'npm' var cmd = npm + ' run --silent install' - exec(cmd, { env: env, cwd: tmp }, function (err, stdout, stderr) { + env = Object.assign(cleanEnv(process.env), env) + + exec(cmd, { env, cwd: tmp }, function (err, stdout, stderr) { t.error(err, 'no error') t.equal(stderr.toString().trim(), '', 'no stderr') diff --git a/test/skip-test.js b/test/skip-test.js new file mode 100644 index 0000000..30b3645 --- /dev/null +++ b/test/skip-test.js @@ -0,0 +1,104 @@ +var test = require('tape') +var path = require('path') +var exec = require('child_process').exec +var execFileSync = require('child_process').execFileSync +var fs = require('fs') +var tempy = require('tempy') // Locked to 0.2.1 for node 6 support +var cleanEnv = require('./util/clean-env') + +// Old npm (v3?) doesn't support the mechanisms of this test +var npm = process.platform === 'win32' ? 'npm.cmd' : 'npm' +var supported = execFileSync(npm, ['-v']).toString().match(/^(\d+)\./)[1] > 3 + +supported && test('skips download in standalone package', function (t) { + run(t, 'standalone', '', function (code, logs) { + t.is(code, 1) + t.is(logs.pop(), 'prebuild-install info install installing standalone, skipping download.') + t.end() + }) +}) + +supported && test('skips download in git dependency', function (t) { + run(t, 'git', '', function (code, logs) { + t.is(code, 1) + t.is(logs.pop(), 'prebuild-install info install installing from git repository, skipping download.') + t.end() + }) +}) + +supported && test('does not skip download in normal dependency', function (t) { + // We're not testing this flag. Just that we don't hit the code paths before it + run(t, 'tarball', '--build-from-source', function (code, logs) { + t.is(code, 1) + t.is(logs.pop(), 'prebuild-install info install --build-from-source specified, not attempting download.') + t.end() + }) +}) + +function run (t, mode, args, cb) { + var addon = tempy.directory() + var cwd = addon + + writePackage(addon, { + name: 'addon', + version: '1.0.0', + dependencies: { + 'prebuild-install': 'file:' + path.dirname(__dirname) + }, + scripts: { + // TODO: npm 7 cannot find "prebuild-install" command in tarball mode + install: 'prebuild-install ' + args + } + }) + + if (mode !== 'standalone') { + // Install as dependency of an app + cwd = tempy.directory() + + writePackage(cwd, { + name: 'app', + dependencies: { + addon: mode === 'git' ? prepareGit(addon) : prepareTarball(addon) + } + }) + } + + var env = Object.assign(cleanEnv(process.env), { + // We shouldn't hit npm or github + npm_config_registry: 'http://localhost:1234', + npm_config_addon_binary_host: 'http://localhost:1234' + }) + + exec(npm + ' install --loglevel=info', { cwd, env, encoding: 'utf8' }, function (err, stdout, stderr) { + cb(err && err.code, logs(stderr)) + }) +} + +function writePackage (cwd, pkg) { + fs.writeFileSync(path.join(cwd, 'package.json'), JSON.stringify(pkg)) +} + +function prepareGit (cwd) { + execFileSync('git', ['init', '.'], { cwd, stdio: 'ignore' }) + execFileSync('git', ['config', 'user.name', 'test'], { cwd, stdio: 'ignore' }) + execFileSync('git', ['config', 'user.email', 'test@localhost'], { cwd, stdio: 'ignore' }) + execFileSync('git', ['add', 'package.json'], { cwd, stdio: 'ignore' }) + execFileSync('git', ['commit', '-m', 'test'], { cwd, stdio: 'ignore' }) + + return 'git+file://' + cwd +} + +function prepareTarball (cwd) { + // Packs to -.tgz + execFileSync(npm, ['pack'], { cwd, stdio: 'ignore' }) + + return 'file:' + path.join(cwd, 'addon-1.0.0.tgz') +} + +function logs (stderr) { + return (stderr || '').split(/\r?\n/).filter(isOurs) +} + +function isOurs (line) { + return /^prebuild-install /.test(line) +} diff --git a/test/util/clean-env.js b/test/util/clean-env.js new file mode 100644 index 0000000..e56fde3 --- /dev/null +++ b/test/util/clean-env.js @@ -0,0 +1,14 @@ +var hasOwnProperty = Object.prototype.hasOwnProperty + +module.exports = function (env) { + var clean = {} + + for (var k in env) { + if (!hasOwnProperty.call(env, k)) continue + if (/^npm_/i.test(k)) continue + + clean[k] = env[k] + } + + return clean +} From c24e6f57b321e53ed2a0b0b681a959e30b5dfe5b Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sat, 17 Oct 2020 15:52:12 +0200 Subject: [PATCH 3/6] Read env.npm_package_from for npm 7 --- bin.js | 5 +++-- util.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/bin.js b/bin.js index c80d006..38330ff 100755 --- a/bin.js +++ b/bin.js @@ -44,16 +44,17 @@ if (napi.isNapiRuntime(rc.runtime)) napi.logUnsupportedVersion(rc.target, log) var pm = whichPmRuns() var isNpm = !pm || pm.name === 'npm' +var origin = util.packageOrigin(process.env, pkg) if (!isNpm && /node_modules/.test(process.cwd())) { // From yarn repository } else if (opts.force) { log.warn('install', 'prebuilt binaries enforced with --force!') log.warn('install', 'prebuilt binaries may be out of date!') -} else if (!(typeof pkg._from === 'string')) { +} else if (typeof origin !== 'string') { log.info('install', 'installing standalone, skipping download.') process.exit(1) -} else if (pkg._from.length > 4 && pkg._from.substr(0, 4) === 'git+') { +} else if (origin.length > 4 && origin.substr(0, 4) === 'git+') { log.info('install', 'installing from git repository, skipping download.') process.exit(1) } else if (opts.compile === true || opts.prebuild === false) { diff --git a/util.js b/util.js index 94f74a3..e16d94f 100644 --- a/util.js +++ b/util.js @@ -87,6 +87,19 @@ function tempFile (cached) { return cached + '.' + process.pid + '-' + Math.random().toString(16).slice(2) + '.tmp' } +function packageOrigin (env, pkg) { + if (env.npm_package_from) { + // npm 7: metadata is exposed to environment by arborist + // TODO: seems undefined atm (npm 7.0.2) + return env.npm_package_from + } + + if (pkg._from) { + // npm <= 6: metadata is stored on disk in node_modules + return pkg._from + } +} + exports.getDownloadUrl = getDownloadUrl exports.getApiUrl = getApiUrl exports.getAssetUrl = getAssetUrl @@ -95,3 +108,4 @@ exports.cachedPrebuild = cachedPrebuild exports.prebuildCache = prebuildCache exports.npmCache = npmCache exports.tempFile = tempFile +exports.packageOrigin = packageOrigin From 80556b56b0f380e7807c86bfc860a4b1ee57a27e Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sat, 17 Oct 2020 16:24:57 +0200 Subject: [PATCH 4/6] Remove use of env.npm_config_argv for npm 7 Instead use npm_config_* which works as far back as npm > 0.1.7. It translates command line flags to environment variables, where: --foo becomes npm_config_foo='true' --no-foo becomes npm_config_foo='' --foo=false becomes npm_config_foo='' --- rc.js | 37 ++++++++++--------------------------- test/rc-test.js | 8 ++++---- 2 files changed, 14 insertions(+), 31 deletions(-) diff --git a/rc.js b/rc.js index 606ad80..86bc06c 100644 --- a/rc.js +++ b/rc.js @@ -4,49 +4,32 @@ var detectLibc = require('detect-libc') var napi = require('napi-build-utils') var env = process.env - var libc = env.LIBC || (detectLibc.isNonGlibcLinux && detectLibc.family) || '' -// Get `prebuild-install` arguments that were passed to the `npm` command -if (env.npm_config_argv) { - var npmargs = ['prebuild', 'compile', 'build-from-source', 'debug', 'verbose'] - try { - var npmArgv = JSON.parse(env.npm_config_argv).cooked - for (var i = 0; i < npmargs.length; ++i) { - if (npmArgv.indexOf('--' + npmargs[i]) !== -1) { - process.argv.push('--' + npmargs[i]) - } - if (npmArgv.indexOf('--no-' + npmargs[i]) !== -1) { - process.argv.push('--no-' + npmargs[i]) - } - } - if ((i = npmArgv.indexOf('--download')) !== -1) { - process.argv.push(npmArgv[i], npmArgv[i + 1]) - } - } catch (e) { } -} - // Get the configuration module.exports = function (pkg) { var pkgConf = pkg.config || {} - var sourceBuild = env.npm_config_build_from_source - var buildFromSource = sourceBuild === pkg.name || sourceBuild === 'true' + + // TODO: remove compile and prebuild aliases? + var buildFromSource = env.npm_config_build_from_source || env.npm_config_compile + var rc = require('rc')('prebuild-install', { target: pkgConf.target || env.npm_config_target || process.versions.node, runtime: pkgConf.runtime || env.npm_config_runtime || 'node', arch: pkgConf.arch || env.npm_config_arch || process.arch, libc: libc, platform: env.npm_config_platform || process.platform, - debug: false, + debug: env.npm_config_debug === 'true', force: false, - verbose: false, - prebuild: true, - compile: buildFromSource, + verbose: env.npm_config_verbose === 'true', + prebuild: env.npm_config_prebuild !== '', + compile: buildFromSource === pkg.name || buildFromSource === 'true', path: '.', proxy: env.npm_config_proxy || env['http_proxy'] || env['HTTP_PROXY'], 'https-proxy': env.npm_config_https_proxy || env['https_proxy'] || env['HTTPS_PROXY'], 'local-address': env.npm_config_local_address, - 'tag-prefix': 'v' + 'tag-prefix': 'v', + download: env.npm_config_download }, minimist(process.argv, { alias: { target: 't', diff --git a/test/rc-test.js b/test/rc-test.js index b80f0f6..9def398 100644 --- a/test/rc-test.js +++ b/test/rc-test.js @@ -55,11 +55,11 @@ test('npm args are passed on from npm environment into rc', function (t) { ].join(' ') runRc(t, args, {}, function (rc) { - t.equal(rc['build-from-source'], true, '--build-from-source works') t.equal(rc.compile, true, 'compile should be true') t.equal(rc.debug, true, 'debug should be true') t.equal(rc.verbose, true, 'verbose should be true') t.equal(rc.download, 'https://foo.bar', 'download is set') + t.equal(rc.prebuild, true, 'prebuild is true') t.end() }) }) @@ -140,16 +140,16 @@ function runRc (t, args, env, cb) { if (err) throw err var npm = process.platform === 'win32' ? 'npm.cmd' : 'npm' - var cmd = npm + ' run --silent install' + var cmd = npm + ' run install' env = Object.assign(cleanEnv(process.env), env) exec(cmd, { env, cwd: tmp }, function (err, stdout, stderr) { t.error(err, 'no error') - t.equal(stderr.toString().trim(), '', 'no stderr') + t.equal(stderr.trim(), '', 'no stderr') try { - var result = JSON.parse(stdout.toString()) + var result = JSON.parse(stdout.slice(stdout.indexOf('{'))) } catch (e) { return t.fail(e) } From e77a2374452d2cc7fd6965a50afa9e6f6732e016 Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sat, 17 Oct 2020 14:42:17 +0200 Subject: [PATCH 5/6] Use env.npm_package_resolved for npm 7 --- .travis.yml | 9 ++++++- log.js | 12 +++++++++ test/skip-test.js | 65 ++++++++++++++++++++++++++++++----------------- util.js | 15 +++++++---- 4 files changed, 71 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 37bce07..4289264 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,11 @@ node_js: - 8 - 10 - 12 - - 14 \ No newline at end of file + - 14 + +jobs: + include: + - name: npm 7 + os: linux + node_js: 14 + before_install: npm i npm@7 -g diff --git a/log.js b/log.js index 707705c..be12d1d 100644 --- a/log.js +++ b/log.js @@ -1,4 +1,6 @@ var log = require('npmlog') +var fs = require('fs') +var path = require('path') module.exports = function (rc, env) { log.heading = 'prebuild-install' @@ -9,5 +11,15 @@ module.exports = function (rc, env) { log.level = env.npm_config_loglevel || 'notice' } + // Temporary workaround for npm 7 which swallows our output + if (process.env.npm_config_prebuild_install_logfile) { + var fp = path.resolve(process.env.npm_config_prebuild_install_logfile) + + log.on('log', function (msg) { + // Only for tests, don't care about performance + fs.appendFileSync(fp, [log.heading, msg.level, msg.prefix, msg.message].join(' ') + '\n') + }) + } + return log } diff --git a/test/skip-test.js b/test/skip-test.js index 30b3645..07cedce 100644 --- a/test/skip-test.js +++ b/test/skip-test.js @@ -5,31 +5,27 @@ var execFileSync = require('child_process').execFileSync var fs = require('fs') var tempy = require('tempy') // Locked to 0.2.1 for node 6 support var cleanEnv = require('./util/clean-env') - -// Old npm (v3?) doesn't support the mechanisms of this test var npm = process.platform === 'win32' ? 'npm.cmd' : 'npm' -var supported = execFileSync(npm, ['-v']).toString().match(/^(\d+)\./)[1] > 3 -supported && test('skips download in standalone package', function (t) { - run(t, 'standalone', '', function (code, logs) { - t.is(code, 1) - t.is(logs.pop(), 'prebuild-install info install installing standalone, skipping download.') +test('skips download in git dependency', function (t) { + // We're not testing this flag. Just that we do hit the code paths before it + run(t, 'git', '--build-from-source', function (logs) { + t.is(logs.pop(), 'prebuild-install info install installing from git repository, skipping download.') t.end() }) }) -supported && test('skips download in git dependency', function (t) { - run(t, 'git', '', function (code, logs) { - t.is(code, 1) - t.is(logs.pop(), 'prebuild-install info install installing from git repository, skipping download.') +test('does not skip download in normal dependency', function (t) { + // We're not testing this flag. Just that we don't hit the code paths before it + run(t, 'tarball', '--build-from-source', function (logs) { + t.is(logs.pop(), 'prebuild-install info install --build-from-source specified, not attempting download.') t.end() }) }) -supported && test('does not skip download in normal dependency', function (t) { +test('does not skip download in standalone package', function (t) { // We're not testing this flag. Just that we don't hit the code paths before it - run(t, 'tarball', '--build-from-source', function (code, logs) { - t.is(code, 1) + run(t, 'standalone', '--build-from-source', function (logs) { t.is(logs.pop(), 'prebuild-install info install --build-from-source specified, not attempting download.') t.end() }) @@ -37,17 +33,14 @@ supported && test('does not skip download in normal dependency', function (t) { function run (t, mode, args, cb) { var addon = tempy.directory() + var logfile = path.join(addon, 'prebuild-install.log') var cwd = addon writePackage(addon, { name: 'addon', version: '1.0.0', - dependencies: { - 'prebuild-install': 'file:' + path.dirname(__dirname) - }, scripts: { - // TODO: npm 7 cannot find "prebuild-install" command in tarball mode - install: 'prebuild-install ' + args + install: 'node ' + path.resolve(__dirname, '..', 'bin.js') + ' ' + args + ' || exit 0' } }) @@ -66,11 +59,22 @@ function run (t, mode, args, cb) { var env = Object.assign(cleanEnv(process.env), { // We shouldn't hit npm or github npm_config_registry: 'http://localhost:1234', - npm_config_addon_binary_host: 'http://localhost:1234' + npm_config_addon_binary_host: 'http://localhost:1234', + npm_config_prefer_offline: 'true', + npm_config_audit: 'false', + + // Temporary workaround for npm 7 which swallows our output + npm_config_prebuild_install_logfile: logfile, + npm_config_loglevel: 'info' }) - exec(npm + ' install --loglevel=info', { cwd, env, encoding: 'utf8' }, function (err, stdout, stderr) { - cb(err && err.code, logs(stderr)) + exec(npm + ' install', { cwd, env }, function (err) { + t.ifError(err, 'no install error') + + fs.readFile(logfile, 'utf8', function (err, data) { + t.ifError(err, 'no read error') + cb(logs(data)) + }) }) } @@ -85,9 +89,18 @@ function prepareGit (cwd) { execFileSync('git', ['add', 'package.json'], { cwd, stdio: 'ignore' }) execFileSync('git', ['commit', '-m', 'test'], { cwd, stdio: 'ignore' }) + if (process.platform === 'win32' && npmVersion() >= 7) { + // Otherwise results in invalid url error + return 'git+file:///' + cwd + } + return 'git+file://' + cwd } +function npmVersion () { + return parseInt(execFileSync(npm, ['-v']).toString()) +} + function prepareTarball (cwd) { // Packs to -.tgz execFileSync(npm, ['pack'], { cwd, stdio: 'ignore' }) @@ -96,9 +109,13 @@ function prepareTarball (cwd) { } function logs (stderr) { - return (stderr || '').split(/\r?\n/).filter(isOurs) + return (stderr || '').split(/\r?\n/).filter(isOurs).map(stripPrefix) } function isOurs (line) { - return /^prebuild-install /.test(line) + return /^(npm ERR! )?prebuild-install /.test(line) +} + +function stripPrefix (line) { + return line.replace(/^npm ERR! /, '') } diff --git a/util.js b/util.js index e16d94f..db358c9 100644 --- a/util.js +++ b/util.js @@ -88,15 +88,20 @@ function tempFile (cached) { } function packageOrigin (env, pkg) { + // npm <= 6: metadata is stored on disk in node_modules + if (pkg._from) { + return pkg._from + } + + // npm 7: metadata is exposed to environment by arborist if (env.npm_package_from) { - // npm 7: metadata is exposed to environment by arborist - // TODO: seems undefined atm (npm 7.0.2) + // NOTE: seems undefined atm (npm 7.0.2) return env.npm_package_from } - if (pkg._from) { - // npm <= 6: metadata is stored on disk in node_modules - return pkg._from + if (env.npm_package_resolved) { + // NOTE: not sure about the difference with _from, but it's all we have + return env.npm_package_resolved } } From ddb8f69d9ae3d47d27344694810c94e2e5f8d8b2 Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sat, 17 Oct 2020 20:32:33 +0200 Subject: [PATCH 6/6] Breaking: don't skip downloads in standalone mode I.e. when running `npm install` in the working directory of a project that uses prebuild-install, you must now run a more explicit `npm install --build-from-source`. This is necessary to support npm 7, where we do not have enough information to automatically determine it and would erroneously skip downloads on normal installs. --- bin.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bin.js b/bin.js index 38330ff..9334662 100755 --- a/bin.js +++ b/bin.js @@ -51,10 +51,7 @@ if (!isNpm && /node_modules/.test(process.cwd())) { } else if (opts.force) { log.warn('install', 'prebuilt binaries enforced with --force!') log.warn('install', 'prebuilt binaries may be out of date!') -} else if (typeof origin !== 'string') { - log.info('install', 'installing standalone, skipping download.') - process.exit(1) -} else if (origin.length > 4 && origin.substr(0, 4) === 'git+') { +} else if (origin && origin.length > 4 && origin.substr(0, 4) === 'git+') { log.info('install', 'installing from git repository, skipping download.') process.exit(1) } else if (opts.compile === true || opts.prebuild === false) {