[
  {
    "path": ".editorconfig",
    "content": "root = true\n\n[*]\nindent_style = tab\nend_of_line = lf\ncharset = utf-8\ntrim_trailing_whitespace = true\ninsert_final_newline = true\n\n[*.yml]\nindent_style = space\nindent_size = 2\n"
  },
  {
    "path": ".gitattributes",
    "content": "* text=auto eol=lf\n"
  },
  {
    "path": ".github/security.md",
    "content": "# Security Policy\n\nTo report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "name: CI\non:\n  - push\n  - pull_request\njobs:\n  test:\n    name: Node.js ${{ matrix.node-version }}\n    runs-on: ubuntu-latest\n    strategy:\n      fail-fast: false\n      matrix:\n        node-version:\n          - 20\n          - 18\n    steps:\n      - uses: actions/checkout@v4\n      - uses: actions/setup-node@v4\n        with:\n          node-version: ${{ matrix.node-version }}\n      - run: npm install\n      - run: npm test\n"
  },
  {
    "path": ".npmrc",
    "content": "package-lock=false\n"
  },
  {
    "path": "license",
    "content": "MIT License\n\nCopyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "package.json",
    "content": "{\n\t\"name\": \"run-node\",\n\t\"version\": \"3.0.0\",\n\t\"description\": \"Run the Node.js binary no matter what\",\n\t\"license\": \"MIT\",\n\t\"repository\": \"sindresorhus/run-node\",\n\t\"funding\": \"https://github.com/sponsors/sindresorhus\",\n\t\"author\": {\n\t\t\"name\": \"Sindre Sorhus\",\n\t\t\"email\": \"sindresorhus@gmail.com\",\n\t\t\"url\": \"https://sindresorhus.com\"\n\t},\n\t\"type\": \"module\",\n\t\"bin\": {\n\t\t\"run-node\": \"./run-node\",\n\t\t\"run-npx\": \"./run-npx\"\n\t},\n\t\"engines\": {\n\t\t\"node\": \">=18\"\n\t},\n\t\"scripts\": {\n\t\t\"test\": \"./run-node --version\"\n\t},\n\t\"files\": [\n\t\t\"run-node\",\n\t\t\"run-npx\"\n\t],\n\t\"keywords\": [\n\t\t\"run\",\n\t\t\"node\",\n\t\t\"nodejs\",\n\t\t\"node.js\",\n\t\t\"npx\",\n\t\t\"npm\",\n\t\t\"find\",\n\t\t\"binary\",\n\t\t\"bin\",\n\t\t\"execute\",\n\t\t\"which\",\n\t\t\"detect\",\n\t\t\"path\",\n\t\t\"env\",\n\t\t\"bash\",\n\t\t\"shell\",\n\t\t\"sh\"\n\t]\n}\n"
  },
  {
    "path": "readme.md",
    "content": "# run-node\n\n> Run the Node.js binary no matter what\n\nYou can't always assume running `$ node file.js` will just work. The user might have the `node` binary in a non-standard location. They might be using a Node.js version manager like `nvm`, which is sourced in a subshell and not available from the outside. Or they might have `node` installed as a local dependency in an npm project. It also depends from where you're trying to run it. For example, GUI apps on macOS doesn't inherit the [`$PATH`](https://en.wikipedia.org/wiki/PATH_(variable)), so the `node` binary would not be found. Most projects that depend on Node.js just end up telling the user to manually set the full path to the `node` binary in some project specific settings. Now every project has to do this. [Ugh...](https://gist.github.com/cookrn/4015437) I prefer things to *just* work. With this module it will.\n\nThis Bash script uses some tricks to find the Node.js binary on your system and run it. A companion `run-npx` script is also provided to reliably run `npx`.\n\nCan be used from any environment that can spawn a process (Shell, Python, Ruby, Swift, Objective-C, etc).\n\n### npm\n\n#### Install\n\n```sh\nnpm install run-node\n```\n\n#### Usage\n\n```sh\n./node_modules/.bin/run-node file.js\n```\n\nOr in an [npm run script](https://docs.npmjs.com/cli/run-script):\n\n```json\n{\n\t\"start\": \"run-node file.js\"\n}\n```\n\nTo run `npx` commands:\n\n```sh\n./node_modules/.bin/run-npx package-name\n```\n\nWhen run within an npm script context, `run-node` will use the same Node.js binary that npm is using (via the `npm_node_execpath` environment variable), ensuring consistency with the parent process. When run directly outside of npm scripts, if the [`node`](https://www.npmjs.com/package/node) package is found in the local `node_modules` directory, that binary will be used instead.\n\n### Manually\n\n#### Install\n\nDownload the [run-node](run-node) file:\n\n```sh\ncurl -sSLO https://github.com/sindresorhus/run-node/raw/main/run-node && chmod +x run-node\n```\n\nFor `npx` support, also download [run-npx](run-npx):\n\n```sh\ncurl -sSLO https://github.com/sindresorhus/run-node/raw/main/run-npx && chmod +x run-npx\n```\n\n#### Usage\n\n```sh\n./run-node file.js\n```\n\nOr with `npx`:\n\n```sh\n./run-npx package-name\n```\n\n#### Customizable cache path and error message\n\nThe cache path and error message are defined by the `RUN_NODE_CACHE_PATH` and `RUN_NODE_ERROR_MSG` environment variables. You could use them in a script or add them to your `~.bashrc`.\n\nDefault config:\n\n```sh\nexport RUN_NODE_ERROR_MSG=\"Couldn't find the Node.js binary. Ensure you have Node.js installed. Open an issue on https://github.com/sindresorhus/run-node\"\nexport RUN_NODE_CACHE_PATH=\"/home/username/.node_path\"\n```\n\nIf the `RUN_NODE_CACHE_PATH` environment variable is defined explicitly, the script it points to will be sourced before looking for a `node` binary. You can use this script to override your `PATH` variable so that a specific `node` binary is found.\n"
  },
  {
    "path": "run-node",
    "content": "#!/usr/bin/env bash\n# MIT License © Sindre Sorhus\n\n# If npm_node_execpath is set and exists, use it directly\nif [[ -n $npm_node_execpath && -x $npm_node_execpath ]]; then\n\texec \"$npm_node_execpath\" \"$@\"\nfi\n\nif [[ -f \"$PWD/node_modules/node/bin/node\" ]]; then\n\tPATH=\"$PWD/node_modules/node/bin:$PATH\"\n\texport PATH\nfi\n\nif [[ -z $RUN_NODE_CACHE_PATH ]]; then\n\tPATH_CACHE=\"$HOME\"/.node_path\nelse\n\tPATH_CACHE=\"$RUN_NODE_CACHE_PATH\"\n\tif [[ -f \"$PATH_CACHE\" ]]; then\n\t\t. \"$PATH_CACHE\"\n\t\texport PATH\n\tfi\nfi\n\nget_user_path() {\n\t[[ -x \"/usr/libexec/path_helper\" ]] && eval $(/usr/libexec/path_helper -s)\n\techo \"$($SHELL -i -l -c 'echo -e \"\\n\"PATH=\\\"$PATH:\\$PATH\\\"\"\\n\"' 2>/dev/null | grep \"^PATH=\")\" > \"$PATH_CACHE\"\n}\n\nset_path() {\n\tif [[ -f \"$PATH_CACHE\" ]]; then\n\t\t. \"$PATH_CACHE\"\n\telse\n\t\tget_user_path\n\t\t. \"$PATH_CACHE\"\n\tfi\n\n\texport PATH\n}\n\nhas_node() {\n\tcommand -v node >/dev/null 2>&1\n}\n\nif ! has_node; then\n\tset_path\n\n\t# Retry by deleting old path cache\n\tif ! has_node; then\n\t\trm \"$PATH_CACHE\"\n\t\tset_path\n\tfi\nfi\n\nif has_node; then\n\tnode \"$@\"\nelse\n\tif [[ -z $RUN_NODE_ERROR_MSG ]]; then\n\t\techo \"Couldn't find the Node.js binary. Ensure you have Node.js installed. Open an issue on https://github.com/sindresorhus/run-node\"\n\telse\n\t\techo \"$RUN_NODE_ERROR_MSG\"\n\tfi\nfi\n"
  },
  {
    "path": "run-npx",
    "content": "#!/usr/bin/env bash\n# MIT License © Sindre Sorhus\n\n# If npm_node_execpath is set and exists, prefer that over local node package\nif [[ -n $npm_node_execpath && -x $npm_node_execpath ]]; then\n\t# Don't add local node to PATH when npm_node_execpath is available\n\t# This ensures consistency with the parent npm process\n\t:\nelif [[ -f \"$PWD/node_modules/node/bin/node\" ]]; then\n\tPATH=\"$PWD/node_modules/node/bin:$PATH\"\n\texport PATH\nfi\n\nif [[ -z $RUN_NODE_CACHE_PATH ]]; then\n\tPATH_CACHE=\"$HOME\"/.node_path\nelse\n\tPATH_CACHE=\"$RUN_NODE_CACHE_PATH\"\n\tif [[ -f \"$PATH_CACHE\" ]]; then\n\t\t. \"$PATH_CACHE\"\n\t\texport PATH\n\tfi\nfi\n\nget_user_path() {\n\t[[ -x \"/usr/libexec/path_helper\" ]] && eval $(/usr/libexec/path_helper -s)\n\techo \"$($SHELL -i -l -c 'echo -e \"\\n\"PATH=\\\"$PATH:\\$PATH\\\"\"\\n\"' 2>/dev/null | grep \"^PATH=\")\" > \"$PATH_CACHE\"\n}\n\nset_path() {\n\tif [[ -f \"$PATH_CACHE\" ]]; then\n\t\t. \"$PATH_CACHE\"\n\telse\n\t\tget_user_path\n\t\t. \"$PATH_CACHE\"\n\tfi\n\n\texport PATH\n}\n\nhas_npx() {\n\tcommand -v npx >/dev/null 2>&1\n}\n\nif ! has_npx; then\n\tset_path\n\n\t# Retry by deleting old path cache\n\tif ! has_npx; then\n\t\trm \"$PATH_CACHE\"\n\t\tset_path\n\tfi\nfi\n\nif has_npx; then\n\tnpx \"$@\"\nelse\n\tif [[ -z $RUN_NODE_ERROR_MSG ]]; then\n\t\techo \"Couldn't find the npx binary. Ensure you have npm/npx installed. Open an issue on https://github.com/sindresorhus/run-node\"\n\telse\n\t\techo \"$RUN_NODE_ERROR_MSG\"\n\tfi\nfi"
  }
]