{"id":15007658,"url":"https://github.com/ehmicky/preferred-node-version","last_synced_at":"2025-05-12T23:09:05.648Z","repository":{"id":40602309,"uuid":"255162725","full_name":"ehmicky/preferred-node-version","owner":"ehmicky","description":"Get the preferred Node.js version of a project or user","archived":false,"fork":false,"pushed_at":"2025-03-29T03:45:49.000Z","size":7671,"stargazers_count":12,"open_issues_count":0,"forks_count":26,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-12T23:08:42.962Z","etag":null,"topics":["bash","cli","command-line","dependency-management","es6","exec","javascript","library","node","nodejs","npmjs","npx","nvm","operating-system","package-manager","shell","terminal","typescript","versioning","versions"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ehmicky.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-12T20:17:39.000Z","updated_at":"2025-05-03T01:01:25.000Z","dependencies_parsed_at":"2024-04-22T20:27:42.880Z","dependency_job_id":"0d577219-6af9-4f94-bbfa-fa756bac498a","html_url":"https://github.com/ehmicky/preferred-node-version","commit_stats":{"total_commits":513,"total_committers":3,"mean_commits":171.0,"dds":0.01754385964912286,"last_synced_commit":"ee8733bc737cc1018c2143c8621d1c8bfe98a072"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehmicky%2Fpreferred-node-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehmicky%2Fpreferred-node-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehmicky%2Fpreferred-node-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehmicky%2Fpreferred-node-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ehmicky","download_url":"https://codeload.github.com/ehmicky/preferred-node-version/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253837407,"owners_count":21971983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","cli","command-line","dependency-management","es6","exec","javascript","library","node","nodejs","npmjs","npx","nvm","operating-system","package-manager","shell","terminal","typescript","versioning","versions"],"created_at":"2024-09-24T19:13:14.151Z","updated_at":"2025-05-12T23:09:05.638Z","avatar_url":"https://github.com/ehmicky.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Node](https://img.shields.io/badge/-Node.js-808080?logo=node.js\u0026colorA=404040\u0026logoColor=66cc33)](https://www.npmjs.com/package/preferred-node-version)\n[![TypeScript](https://img.shields.io/badge/-Typed-808080?logo=typescript\u0026colorA=404040\u0026logoColor=0096ff)](/src/main.d.ts)\n[![Codecov](https://img.shields.io/badge/-Tested%20100%25-808080?logo=codecov\u0026colorA=404040)](https://codecov.io/gh/ehmicky/preferred-node-version)\n[![Mastodon](https://img.shields.io/badge/-Mastodon-808080.svg?logo=mastodon\u0026colorA=404040\u0026logoColor=9590F9)](https://fosstodon.org/@ehmicky)\n[![Medium](https://img.shields.io/badge/-Medium-808080.svg?logo=medium\u0026colorA=404040)](https://medium.com/@ehmicky)\n\nGet the preferred Node.js version of a user or project.\n\nThis looks for (from highest to lowest priority):\n\n- Any [`.n-node-version`](https://github.com/tj/n#specifying-node-versions),\n  [`.naverc`](https://github.com/isaacs/nave#automagical),\n  [`.node-version`](https://github.com/jasongin/nvs#automatic-switching-per-directory),\n  [`.nodeenvrc`](https://github.com/ekalinin/nodeenv#configuration)\n  [`.nvmrc`](https://github.com/nvm-sh/nvm#nvmrc) or\n  [`package.json` (`engines.node` field)](https://docs.npmjs.com/files/package.json#engines)\n  in the current directory, parent directories, or home directory\n- Any\n  [`NODE_VERSION`](https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript),\n  [`NODIST_NODE_VERSION`](https://github.com/nullivex/nodist#scope-precedence)\n  environment variable\n\n`nvm` aliases (like `current` or `lts/erbium`) and version ranges (like `12` or\n`\u003e=12`) are resolved to regular `\"major.minor.patch\"` version strings.\n\n# Examples\n\n```js\nimport preferredNodeVersion from 'preferred-node-version'\n\n// Look for any `.nvmrc` or `package.json` (`engines.node` field)\nconst { version } = await preferredNodeVersion()\nconsole.log(version) // 12.10.0\n```\n\n```js\n// Search only the home directory and environment variables\nawait preferredNodeVersion({ global: true })\n```\n\n```js\n// Start looking for a Node.js version file from this directory instead\nawait preferredNodeVersion({ cwd: '/path/to/cwd' })\n```\n\n```js\n// Search for specific files\nawait preferredNodeVersion({\n  files: ['/path/to/.nvmrc', '/path/to/package.json'],\n})\n```\n\n# Install\n\n```bash\nnpm install preferred-node-version\n```\n\nThis package works in Node.js \u003e=18.18.0.\n\nThis is an ES module. It must be loaded using\n[an `import` or `import()` statement](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c),\nnot `require()`. If TypeScript is used, it must be configured to\n[output ES modules](https://www.typescriptlang.org/docs/handbook/esm-node.html),\nnot CommonJS.\n\n# Usage\n\n## preferredNodeVersion(options?)\n\n`options`: `object?`\\\n_Returns_: `Promise\u003cobject\u003e`\n\n### Return value\n\nThe returned promise resolves to an object with the following properties. An\nempty object is returned if no preferred Node.js version was found.\n\nIf a file cannot be read or if it contains an invalid version, the promise is\nrejected with an error.\n\n#### version\n\n_Type_: `string`\n\nFull Node.js version. For example `12.16.2`\n\n#### rawVersion\n\n_Type_: `string`\n\nNode.js version as specified in the Node.js version file. This might include\naliases or version ranges. For example `latest`, `lts/erbium`, `12` or\n`12.16.2`.\n\n#### filePath\n\n_Type_: `string?`\n\nAbsolute path to the Node.js version file. Either `filePath` or `envVariable` is\ndefined.\n\n#### envVariable\n\n_Type_: `string?`\n\nName of the environment variable containing the version. For example\n`NODE_VERSION`. Either `filePath` or `envVariable` is defined.\n\n### options\n\n#### cwd\n\n_Type_: `string | URL`\\\n_Default_: `process.cwd()`\n\nStart looking for a Node.js version file from this directory.\n\n#### global\n\n_Type_: `boolean`\\\n_Default_: `false`\n\nIf `true`, find the global Node.js version instead:\n\n- use only the home directory and environment variables\n- ignore the current directory and parent directories\n\n#### files\n\n_Type_: `string[]`\\\n_Default_: `[]`\n\nAdditional files to lookup. Their filenames must be one of `package.json`,\n`.nvmrc`, etc.\n\n#### mirror\n\n_Type_: `string`\\\n_Default_: `https://nodejs.org/dist`\n\nBase URL to fetch the list of available Node.js versions. Can be customized (for\nexample `https://npmmirror.com/mirrors/node`).\n\nThe following environment variables can also be used: `NODE_MIRROR`,\n`NVM_NODEJS_ORG_MIRROR`, `N_NODE_MIRROR` or `NODIST_NODE_MIRROR`.\n\n#### fetch\n\n_Type_: `boolean`\\\n_Default_: `undefined`\n\nThe list of available Node.js versions is cached for one hour by default. If the\n`fetch` option is:\n\n- `true`: the cache will not be used\n- `false`: the cache will be used even if it's older than one hour\n\n#### signal\n\n_Type_:\n[`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\nCancels when the signal is aborted.\n\n## NODE_VERSION_FILES\n\n_Type_: `string[]`\n\nList of filenames being searched: `.nvmrc`, `package.json`, etc.\n\n# See also\n\n- [`nve`](https://github.com/ehmicky/nve): Run a specific Node.js version (CLI)\n- [`nvexeca`](https://github.com/ehmicky/nve): Run a specific Node.js version\n  (programmatic)\n- [`get-node`](https://github.com/ehmicky/get-node): Download Node.js\n- [`normalize-node-version`](https://github.com/ehmicky/normalize-node-version):\n  Normalize and validate Node.js versions\n- [`node-version-alias`](https://github.com/ehmicky/node-version-alias): Resolve\n  Node.js version aliases like `latest`, `lts` or `erbium`\n- [`all-node-versions`](https://github.com/ehmicky/all-node-versions): List all\n  available Node.js versions\n- [`fetch-node-website`](https://github.com/ehmicky/fetch-node-website): Fetch\n  releases on nodejs.org\n\n# Support\n\nFor any question, _don't hesitate_ to [submit an issue on GitHub](../../issues).\n\nEveryone is welcome regardless of personal background. We enforce a\n[Code of conduct](CODE_OF_CONDUCT.md) in order to promote a positive and\ninclusive environment.\n\n# Contributing\n\nThis project was made with ❤️. The simplest way to give back is by starring and\nsharing it online.\n\nIf the documentation is unclear or has a typo, please click on the page's `Edit`\nbutton (pencil icon) and suggest a correction.\n\nIf you would like to help us fix a bug or add a new feature, please check our\n[guidelines](CONTRIBUTING.md). Pull requests are welcome!\n\nThanks go to our wonderful contributors:\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\"\u003e\u003ca href=\"https://fosstodon.org/@ehmicky\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/8136211?v=4?s=100\" width=\"100px;\" alt=\"ehmicky\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eehmicky\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/ehmicky/preferred-node-version/commits?author=ehmicky\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#design-ehmicky\" title=\"Design\"\u003e🎨\u003c/a\u003e \u003ca href=\"#ideas-ehmicky\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e \u003ca href=\"https://github.com/ehmicky/preferred-node-version/commits?author=ehmicky\" title=\"Documentation\"\u003e📖\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\u003ca href=\"https://twitter.com/adrieankhisbe\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/2601132?v=4?s=100\" width=\"100px;\" alt=\"Adrien Becchis\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAdrien Becchis\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/ehmicky/preferred-node-version/commits?author=AdrieanKhisbe\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/ehmicky/preferred-node-version/commits?author=AdrieanKhisbe\" title=\"Tests\"\u003e⚠️\u003c/a\u003e \u003ca href=\"#ideas-AdrieanKhisbe\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/shuhrat\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/104213?v=4?s=100\" width=\"100px;\" alt=\"Шухрат Шадмонов\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eШухрат Шадмонов\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-shuhrat\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e \u003ca href=\"#question-shuhrat\" title=\"Answering Questions\"\u003e💬\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehmicky%2Fpreferred-node-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehmicky%2Fpreferred-node-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehmicky%2Fpreferred-node-version/lists"}