Skip to content

[fix] npm build fails with Node.js versions that don't provide os.machine #1831

Open
@mureinik

Description

@mureinik

Describe the bug

Node.js version: 18.0.0

OS version:
Darwin BD-MB61360 23.6.0 Darwin Kernel Version 23.6.0: Thu Sep 12 23:36:12 PDT 2024; root:xnu-10063.141.1.701.1~1/RELEASE_ARM64_T6020 arm64

Description:
Superagent depends on formidable@^3.5.2. formidable@3.5.3 (releases a day ago) uses os.machine, which was introduced in Node.js 18.9.0. This is incompatible with Superagent's engines declaration of "node": ">=14.18.0".

Actual behavior

npm test fails with the following error:

TypeError: os.machine is not a function
    at Object.<anonymous> (/Users/allon/src/git/superagent/node_modules/formidable/dist/index.cjs:1002:91)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module.replacementCompile (/Users/allon/src/git/superagent/node_modules/append-transform/index.js:60:13)
    at module.exports (/Users/allon/src/git/superagent/node_modules/default-require-extensions/js.js:7:9)
    at Object.<anonymous> (/Users/allon/src/git/superagent/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:827:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/allon/src/git/superagent/lib/node/index.js:4:704)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module.replacementCompile (/Users/allon/src/git/superagent/node_modules/append-transform/index.js:60:13)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Object.<anonymous> (/Users/allon/src/git/superagent/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:827:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/allon/src/git/superagent/test/support/client.js:1:17)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module.replacementCompile (/Users/allon/src/git/superagent/node_modules/append-transform/index.js:60:13)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Object.<anonymous> (/Users/allon/src/git/superagent/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:827:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/allon/src/git/superagent/test/agent-base.js:4:17)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module.replacementCompile (/Users/allon/src/git/superagent/node_modules/append-transform/index.js:60:13)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Object.<anonymous> (/Users/allon/src/git/superagent/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:827:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at /Users/allon/src/git/superagent/node_modules/mocha/lib/mocha.js:334:36
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (/Users/allon/src/git/superagent/node_modules/mocha/lib/mocha.js:331:14)
    at Mocha.run (/Users/allon/src/git/superagent/node_modules/mocha/lib/mocha.js:809:10)
    at exports.singleRun (/Users/allon/src/git/superagent/node_modules/mocha/lib/cli/run-helpers.js:108:16)
    at exports.runMocha (/Users/allon/src/git/superagent/node_modules/mocha/lib/cli/run-helpers.js:142:13)
    at exports.handler (/Users/allon/src/git/superagent/node_modules/mocha/lib/cli/run.js:292:3)
    at Object.runCommand (/Users/allon/src/git/superagent/node_modules/mocha/node_modules/yargs/lib/command.js:242:26)
    at Object.parseArgs [as _parseArgs] (/Users/allon/src/git/superagent/node_modules/mocha/node_modules/yargs/yargs.js:1096:28)
    at Object.parse (/Users/allon/src/git/superagent/node_modules/mocha/node_modules/yargs/yargs.js:575:25)
    at exports.main (/Users/allon/src/git/superagent/node_modules/mocha/lib/cli/cli.js:68:6)
    at Object.<anonymous> (/Users/allon/src/git/superagent/node_modules/mocha/lib/cli/cli.js:73:11)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module.replacementCompile (/Users/allon/src/git/superagent/node_modules/append-transform/index.js:60:13)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Object.<anonymous> (/Users/allon/src/git/superagent/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:827:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

Expected behavior

npm build should succeed.

Code to reproduce

Run npm test on Node.js 18.0.0.

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working - not relevant, this bug report is about support of an older Node.js version

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions