{"id":14732,"library":"node-darwin-x64","title":"Node.js Runtime (macOS x64 Binary)","description":"The `node-darwin-x64` package provides a pre-compiled Node.js runtime specifically for macOS (x64 architecture), currently at version 24.15.0. It enables developers to include a specific Node.js version directly within their project's dependencies, facilitating consistent environments for builds, tests, or embedded applications without relying on a system-wide Node.js installation. Node.js itself is an open-source, cross-platform JavaScript runtime environment that follows a predictable release cadence. New major versions are released every six months in April and October, which may introduce breaking changes. Even-numbered major versions are designated as Long Term Support (LTS) releases, offering 12 months of active support followed by 18 months of maintenance, focusing on stability and security.","status":"active","version":"24.15.0","language":"javascript","source_language":"en","source_url":"https://github.com/aredridel/node-bin-gen","tags":["javascript"],"install":[{"cmd":"npm install node-darwin-x64","lang":"bash","label":"npm"},{"cmd":"yarn add node-darwin-x64","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-darwin-x64","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package provides the Node.js runtime environment. These are standard Node.js built-in module imports used *within* the provided runtime, not directly exported by `node-darwin-x64` itself. Use the `node:` protocol for clarity and future-proofing in ESM contexts.","wrong":"import fs from 'fs';","symbol":"fs","correct":"import fs from 'node:fs';"},{"note":"This package provides the Node.js runtime environment. These are standard Node.js built-in module imports used *within* the provided runtime, not directly exported by `node-darwin-x64` itself. While `require()` is valid in CommonJS, `import` with the `node:` protocol is preferred for modern ESM.","wrong":"const http = require('http');","symbol":"http","correct":"import { createServer } from 'node:http';"},{"note":"`process` is a global object in Node.js, often accessed directly without explicit import. However, for explicit declaration in ESM, `import process from 'node:process';` is the correct pattern. This package provides the Node.js runtime that makes `process` available.","wrong":"import { arch } from 'process';","symbol":"process","correct":"import process from 'node:process';"}],"quickstart":{"code":"import { execSync } from 'node:child_process';\nimport { writeFileSync, unlinkSync } from 'node:fs';\nimport { join } from 'node:path';\n\n// Create a simple script to demonstrate running Node.js\nconst scriptContent = `\n  console.log('Hello from Node.js (v' + process.version + ') provided by node-darwin-x64!');\n  console.log('Current architecture:', process.arch);\n  console.log('Current platform:', process.platform);\n  console.log('Environment variable GREETING:', process.env.GREETING ?? 'not set');\n`;\n\nconst scriptFilePath = join(process.cwd(), 'hello-node.js');\nwriteFileSync(scriptFilePath, scriptContent);\n\nconsole.log('Executing script using the Node.js runtime bundled by node-darwin-x64...');\n\ntry {\n  // Option 1: Using 'npx' (recommended for convenience)\n  // 'npx' automatically finds executables installed in node_modules/.bin\n  console.log('\\n--- Running via npx ---');\n  const outputNpx = execSync('npx node hello-node.js', {\n    env: { ...process.env, GREETING: 'Hello from npx' },\n    encoding: 'utf8', \n    stdio: 'pipe' // Capture output\n  });\n  console.log(outputNpx);\n\n  // Option 2: Directly referencing the binary path\n  // Useful for explicit control or when 'npx' is not available\n  const nodeBinaryPath = join(process.cwd(), 'node_modules', '.bin', 'node');\n  console.log(`\\n--- Running directly from ${nodeBinaryPath} ---`);\n  const outputDirect = execSync(`${nodeBinaryPath} hello-node.js`, {\n    env: { ...process.env, GREETING: 'Hello directly' },\n    encoding: 'utf8', \n    stdio: 'pipe' // Capture output\n  });\n  console.log(outputDirect);\n\n} catch (error) {\n  console.error('Error running script:', error.message);\n  if (error.stderr) console.error('Stderr:', error.stderr);\n} finally {\n  unlinkSync(scriptFilePath); // Clean up the temporary script\n  console.log('\\nCleaned up temporary script: hello-node.js');\n}","lang":"javascript","description":"This quickstart demonstrates how to execute a Node.js script using the specific `node` executable provided by the `node-darwin-x64` package, leveraging `npx` or direct path access."},"warnings":[{"fix":"Review the official Node.js release notes and migration guides for each new major version. Pin your project to a specific `node-darwin-x64` version to control the Node.js runtime until you are ready to upgrade and adapt your code.","message":"Node.js major versions, released every April and October, frequently introduce breaking changes. Projects relying on a specific Node.js version provided by this package should be prepared for potential incompatibilities when upgrading to a new major version.","severity":"breaking","affected_versions":">=24.0.0"},{"fix":"Always use `npx node <script.js>` to ensure the Node.js version bundled with the package is used, or explicitly call the executable at `$(npm bin)/node <script.js>` or `node_modules/.bin/node <script.js>`.","message":"This package provides a `node` executable in `node_modules/.bin`. If a system-wide Node.js installation is also present, or if your PATH is configured differently, you might inadvertently use the wrong Node.js version. This can lead to inconsistent behavior or build failures.","severity":"gotcha","affected_versions":">=24.0.0"},{"fix":"Understand that `node-darwin-x64` provides the Node.js *runtime executable*. To use Node.js features, you `import` or `require` built-in Node.js modules (e.g., `node:fs`, `node:http`) or third-party npm packages within the context of a script executed by the bundled Node.js.","message":"This package is a binary distribution and does not export any JavaScript modules directly. Attempts to `import` or `require` symbols directly from `'node-darwin-x64'` will result in errors.","severity":"gotcha","affected_versions":">=24.0.0"},{"fix":"Ensure your project's security practices include auditing third-party binary dependencies. Verify checksums if possible, or restrict usage to trusted CI/CD environments.","message":"As a binary distribution, this package downloads pre-compiled Node.js executables. This introduces a supply chain dependency on the integrity of the original Node.js binaries and the `aredridel/node-bin-gen` repository.","severity":"gotcha","affected_versions":">=24.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Execute your script using `npx node your-script.js` or specify the full path to the bundled Node.js executable: `node_modules/.bin/node your-script.js`.","cause":"The system's PATH environment variable does not include the `node_modules/.bin` directory, or you are not using a tool like `npx` that resolves local binaries.","error":"sh: node: command not found"},{"fix":"For third-party modules, ensure `npm install some-module` has been run. For built-in modules, verify the correct module name and use the `node:` prefix (e.g., `node:fs`). If using ESM, check `package.json` for `\"type\": \"module\"` and correct import paths.","cause":"A required module (either built-in or third-party) cannot be found by the Node.js runtime. This could be due to a missing `npm install` for third-party modules or a typo in a built-in module name.","error":"Error: Cannot find module 'some-module'"}],"ecosystem":"npm"}