{"id":13455044,"url":"https://github.com/nodenv/nodenv","last_synced_at":"2025-05-13T15:12:20.811Z","repository":{"id":38326045,"uuid":"8685986","full_name":"nodenv/nodenv","owner":"nodenv","description":"Manage multiple NodeJS versions.","archived":false,"fork":false,"pushed_at":"2024-12-04T20:24:04.000Z","size":882,"stargazers_count":2288,"open_issues_count":9,"forks_count":146,"subscribers_count":27,"default_branch":"main","last_synced_at":"2025-04-23T18:59:04.841Z","etag":null,"topics":["node","nodejs","nodenv","shell","version-manager"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nodenv.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2013-03-10T14:07:17.000Z","updated_at":"2025-04-22T05:22:54.000Z","dependencies_parsed_at":"2024-06-19T02:49:52.117Z","dependency_job_id":"73de4cde-aa4e-45d3-b20d-88ece8d77a07","html_url":"https://github.com/nodenv/nodenv","commit_stats":{"total_commits":798,"total_committers":136,"mean_commits":5.867647058823529,"dds":0.7756892230576441,"last_synced_commit":"a0089384b7c4e8fba66ebb90dad255311e49f44e"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodenv%2Fnodenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodenv%2Fnodenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodenv%2Fnodenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodenv%2Fnodenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nodenv","download_url":"https://codeload.github.com/nodenv/nodenv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253969265,"owners_count":21992264,"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":["node","nodejs","nodenv","shell","version-manager"],"created_at":"2024-07-31T08:01:00.609Z","updated_at":"2025-05-13T15:12:15.791Z","avatar_url":"https://github.com/nodenv.png","language":"Shell","funding_links":[],"categories":["Packages","Development","开源工具","Repository","Shell","包","目录","✅ 必須要件","Package manager","List of \\*env-, ch\\*- and \\*vm- style version managers","Version Managers"],"sub_categories":["Node.js management","Time Series","命令行工具","Node.js Management","Node.js\u0026nbsp;管理","Node.js管理工具","Node.js 管理","Node.js"],"readme":"# Seamlessly manage your app’s Node environment with nodenv.\n\nUse nodenv to pick a Node version for your application and guarantee\nthat your development environment matches production. Put nodenv to work\nwith [npm](https://www.npmjs.com/) for painless Node upgrades and\nbulletproof deployments.\n\n**Powerful in development.** Specify your app's Node version once,\n  in a single file. Keep all your teammates on the same page. No\n  headaches running apps on different versions of Node. Just Works™\n  from the command line.\n  Override the Node version anytime: just set an environment variable.\n\n**Rock-solid in production.** Your application's executables are its\n  interface with ops. With nodenv and you'll never again need to `cd`\n  in a cron job or Chef recipe to ensure you've selected the right runtime.\n  The Node version dependency lives in one place—your app—so upgrades and\n  rollbacks are atomic, even when you switch versions.\n\n**One thing well.** nodenv is concerned solely with switching Node\n  versions. It's simple and predictable. A rich plugin ecosystem lets\n  you tailor it to suit your needs. Compile your own Node versions, or\n  use the [node-build][]\n  plugin to automate the process. Specify per-application environment\n  variables with [nodenv-vars](https://github.com/nodenv/nodenv-vars).\n  See more [plugins on the\n  wiki](https://github.com/nodenv/nodenv/wiki/Plugins).\n\n[**Why choose nodenv?**](https://github.com/nodenv/nodenv/wiki/Why-nodenv%3F)\n\n## Table of Contents\n\n\u003c!-- toc --\u003e\n\n- [How It Works](#how-it-works)\n  * [Understanding PATH](#understanding-path)\n  * [Understanding Shims](#understanding-shims)\n  * [Choosing the Node Version](#choosing-the-node-version)\n  * [Locating the Node Installation](#locating-the-node-installation)\n- [Installation](#installation)\n  * [Using Package Managers](#using-package-managers)\n  * [Basic GitHub Checkout](#basic-github-checkout)\n    + [Upgrading with Git](#upgrading-with-git)\n    + [Updating the list of available Node versions](#updating-the-list-of-available-node-versions)\n  * [How nodenv hooks into your shell](#how-nodenv-hooks-into-your-shell)\n  * [Installing Node versions](#installing-node-versions)\n  * [Uninstalling Node versions](#uninstalling-node-versions)\n  * [Uninstalling nodenv](#uninstalling-nodenv)\n- [Command Reference](#command-reference)\n  * [nodenv local](#nodenv-local)\n  * [nodenv global](#nodenv-global)\n  * [nodenv shell](#nodenv-shell)\n  * [nodenv versions](#nodenv-versions)\n  * [nodenv version](#nodenv-version)\n  * [nodenv rehash](#nodenv-rehash)\n  * [nodenv which](#nodenv-which)\n  * [nodenv whence](#nodenv-whence)\n- [Environment variables](#environment-variables)\n- [Development](#development)\n  * [Credits](#credits)\n\n\u003c!-- tocstop --\u003e\n\n## How It Works\n\nAt a high level, nodenv intercepts Node commands using shim\nexecutables injected into your `PATH`, determines which Node version\nhas been specified by your application, and passes your commands along\nto the correct Node installation.\n\n### Understanding PATH\n\nWhen you run a command like `node` or `npm`, your operating system\nsearches through a list of directories to find an executable file with\nthat name. This list of directories lives in an environment variable\ncalled `PATH`, with each directory in the list separated by a colon:\n\n    /usr/local/bin:/usr/bin:/bin\n\nDirectories in `PATH` are searched from left to right, so a matching\nexecutable in a directory at the beginning of the list takes\nprecedence over another one at the end. In this example, the\n`/usr/local/bin` directory will be searched first, then `/usr/bin`,\nthen `/bin`.\n\n### Understanding Shims\n\nnodenv works by inserting a directory of _shims_ at the front of your\n`PATH`:\n\n    ~/.nodenv/shims:/usr/local/bin:/usr/bin:/bin\n\nThrough a process called _rehashing_, nodenv maintains shims in that\ndirectory to match every Node command across every installed version\nof Node—`node`, `npm`, and so on.\n\nShims are lightweight executables that simply pass your command along\nto nodenv. So with nodenv installed, when you run, say, `npm`, your\noperating system will do the following:\n\n* Search your `PATH` for an executable file named `npm`\n* Find the nodenv shim named `npm` at the beginning of your `PATH`\n* Run the shim named `npm`, which in turn passes the command along to\n  nodenv\n\n### Choosing the Node Version\n\nWhen you execute a shim, nodenv determines which Node version to use by\nreading it from the following sources, in this order:\n\n1. The `NODENV_VERSION` environment variable, if specified. You can use\n   the [`nodenv shell`](#nodenv-shell) command to set this environment\n   variable in your current shell session.\n\n2. The first `.node-version` file found by searching the directory of the\n   script you are executing and each of its parent directories until reaching\n   the root of your filesystem.\n\n3. The first `.node-version` file found by searching the current working\n   directory and each of its parent directories until reaching the root of your\n   filesystem. You can modify the `.node-version` file in the current working\n   directory with the [`nodenv local`](#nodenv-local) command.\n\n4. The global `~/.nodenv/version` file. You can modify this file using\n   the [`nodenv global`](#nodenv-global) command. If the global version\n   file is not present, nodenv assumes you want to use the \"system\"\n   Node—i.e. whatever version would be run if nodenv weren't in your\n   path.\n\n### Locating the Node Installation\n\nOnce nodenv has determined which version of Node your application has\nspecified, it passes the command along to the corresponding Node\ninstallation.\n\nEach Node version is installed into its own directory under\n`~/.nodenv/versions`. For example, you might have these versions\ninstalled:\n\n* `~/.nodenv/versions/0.10.36/`\n* `~/.nodenv/versions/0.12.0/`\n* `~/.nodenv/versions/iojs-1.0.0/`\n\nVersion names to nodenv are simply the names of the directories or symlinks in\n`~/.nodenv/versions`.\n\n## Installation\n\n### Using Package Managers\n\n1. Install nodenv using one of the following approaches.\n\n   #### Homebrew\n   \n   On macOS or Linux, we recommend installing nodenv with [Homebrew](https://brew.sh).\n   \n   ```sh\n   brew install nodenv\n   ```\n   \n   #### Debian, Ubuntu, and their derivatives\n       \n   Presently, `nodenv` is not available in the Debian or Ubuntu package\n   repositories.\n   [Consider contributing!](https://github.com/nodenv/nodenv/issues/210) \n   \n   #### Arch Linux and its derivatives\n   \n   Archlinux has an [AUR Package](https://aur.archlinux.org/packages/nodenv/) for\n   nodenv and you can install it from the AUR using the instructions from this\n   [wiki page](https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_and_upgrading_packages).\n\n2. Set up nodenv in your shell.\n\n    ```sh\n    nodenv init\n    ```\n\n   Follow the printed instructions to [set up nodenv shell integration](#how-nodenv-hooks-into-your-shell).\n\n3. Close your Terminal window and open a new one so your changes take\n   effect.\n\n4. Verify that nodenv is properly set up using this [nodenv-doctor][] script:\n\n    ```sh\n    curl -fsSL https://github.com/nodenv/nodenv-installer/raw/main/bin/nodenv-doctor | bash\n    ```\n\n    ```sh\n    Checking for `nodenv' in PATH: /usr/local/bin/nodenv\n    Checking for nodenv shims in PATH: OK\n    Checking `nodenv install' support: /usr/local/bin/nodenv-install (node-build 3.0.22-4-g49c4cb9)\n    Counting installed Node versions: none\n      There aren't any Node versions installed under `~/.nodenv/versions'.\n      You can install Node versions like so: nodenv install 2.2.4\n    Auditing installed plugins: OK\n    ```\n\n5. That's it! Installing nodenv includes node-build, so now you're ready to\n   [install some Node versions](#installing-node-versions) using\n   `nodenv install`.\n\n\n### Basic GitHub Checkout\n\nFor a more automated install, you can use [nodenv-installer][].\nIf you prefer a manual approach, follow the steps below.\n\nThis will get you going with the latest version of nodenv without needing\na systemwide install.\n\n1. Clone nodenv into `~/.nodenv`.\n\n\n    ```sh\n    git clone https://github.com/nodenv/nodenv.git ~/.nodenv\n    ```\n\n    Optionally, try to compile dynamic bash extension to speed up nodenv. Don't\n    worry if it fails; nodenv will still work normally:\n\n    ```sh\n    cd ~/.nodenv \u0026\u0026 src/configure \u0026\u0026 make -C src\n    ```\n\n2. Add `~/.nodenv/bin` to your `$PATH` for access to the `nodenv`\n   command-line utility.\n\n   * For **bash**:\n\n     Ubuntu Desktop users should configure `~/.bashrc`:\n     ```bash\n     echo 'export PATH=\"$HOME/.nodenv/bin:$PATH\"' \u003e\u003e ~/.bashrc\n     ```\n\n     On other platforms, bash is usually configured via `~/.bash_profile`:\n     ```bash\n     echo 'export PATH=\"$HOME/.nodenv/bin:$PATH\"' \u003e\u003e ~/.bash_profile\n     ```\n\n   * For **Zsh**:\n     ```zsh\n     echo 'export PATH=\"$HOME/.nodenv/bin:$PATH\"' \u003e\u003e ~/.zshrc\n     ```\n\n   * For **Fish shell**:\n     ```fish\n     set -Ux fish_user_paths $HOME/.nodenv/bin $fish_user_paths\n     ```\n\n3. Set up nodenv in your shell.\n\n   ```sh\n   ~/.nodenv/bin/nodenv init\n   ```\n\n   Follow the printed instructions to [set up nodenv shell integration](#how-nodenv-hooks-into-your-shell).\n\n4. Restart your shell so that PATH changes take effect. (Opening a new\n   terminal tab will usually do it.)\n\n5. Verify that nodenv is properly set up using this [nodenv-doctor][] script:\n\n    ```sh\n    curl -fsSL https://github.com/nodenv/nodenv-installer/raw/main/bin/nodenv-doctor | bash\n    ```\n\n    ```sh\n    Checking for `nodenv' in PATH: /usr/local/bin/nodenv\n    Checking for nodenv shims in PATH: OK\n    Checking `nodenv install' support: /usr/local/bin/nodenv-install (node-build 3.0.22-4-g49c4cb9)\n    Counting installed Node versions: none\n      There aren't any Node versions installed under `~/.nodenv/versions'.\n      You can install Node versions like so: nodenv install 2.2.4\n    Auditing installed plugins: OK\n    ```\n\n6. _(Optional)_ Install [node-build][], which provides the\n   `nodenv install` command that simplifies the process of\n   [installing new Node versions](#installing-node-versions).\n\n#### Upgrading with Git\n\nIf you've installed nodenv manually using Git, you can upgrade to the\nlatest version by pulling from GitHub:\n\n```sh\ncd ~/.nodenv\ngit pull\n```\n\nTo use a specific release of nodenv, check out the corresponding tag:\n\n~~~ sh\n$ cd ~/.nodenv\n$ git fetch\n$ git checkout v0.3.0\n~~~\n\nAlternatively, check out the [nodenv-update][] plugin which provides a\ncommand to update nodenv along with all installed plugins.\n\n```sh\n$ nodenv update\n```\n\n#### Updating the list of available Node versions\n\nIf you're using the `nodenv install` command, then the list of available Node versions is not automatically updated when pulling from the nodenv repo.\nTo do this manually:\n\n```sh\ncd ~/.nodenv/plugins/node-build\ngit pull\n```\n\n### How nodenv hooks into your shell\n\nSkip this section unless you must know what every line in your shell\nprofile is doing.\n\n`nodenv init` is the only command that crosses the line of loading\nextra commands into your shell. Here's what `nodenv init` actually does:\n\n1. Sets up your shims path. This is the only requirement for nodenv to\n   function properly. You can do this by hand by prepending\n   `~/.nodenv/shims` to your `$PATH`.\n\n2. Installs autocompletion. This is entirely optional but pretty\n   useful. Sourcing `~/.nodenv/completions/nodenv.bash` will set that\n   up. There is also a `~/.nodenv/completions/nodenv.zsh` for Zsh\n   users.\n\n3. Rehashes shims. From time to time you'll need to rebuild your\n   shim files. Doing this automatically makes sure everything is up to\n   date. You can always run `nodenv rehash` manually.\n\n4. Installs the sh dispatcher. This bit is also optional, but allows\n   nodenv and plugins to change variables in your current shell, making\n   commands like `nodenv shell` possible. The sh dispatcher doesn't do\n   anything invasive like override `cd` or hack your shell prompt, but if\n   for some reason you need `nodenv` to be a real script rather than a\n   shell function, you can safely skip it.\n\nRun `nodenv init -` for yourself to see exactly what happens under the\nhood.\n\n### Installing Node versions\n\nThe `nodenv install` command doesn't ship with nodenv out of the box, but is\nprovided by the [node-build][] project. If you installed it as part of GitHub\ncheckout process outlined above you should be able to:\n\n```sh\n# list latest stable versions:\nnodenv install -l\n\n# list all local versions:\nnodenv install -L\n\n# install a Node version:\nnodenv install 16.13.2\n```\n\nSet a Node version to finish installation and start using commands `nodenv global 18.14.1` or `nodenv local 18.14.1`\n\nAlternatively to the `install` command, you can download and compile\nNode manually as a subdirectory of `~/.nodenv/versions/`. An entry in\nthat directory can also be a symlink to a Node version installed\nelsewhere on the filesystem. nodenv doesn't care; it will simply treat\nany entry in the `versions/` directory as a separate Node version.\nAdditionally, `nodenv` has special support for an `lts/` subdirectory inside\n`versions/`. This works great with the\n[`nodenv-aliases`](https://github.com/nodenv/nodenv-aliases) plugin, for example:\n\n```sh\ncd ~/.nodenv/versions\nmkdir lts\n\n# Create a symlink that allows to use \"lts/erbium\" as a nodenv version\n# that always points to the latest Node 12 version that is installed.\nln -s ../12 lts/erbium\n```\n\n### Uninstalling Node versions\n\nAs time goes on, Node versions you install will accumulate in your\n`~/.nodenv/versions` directory.\n\nTo remove old Node versions, simply `rm -rf` the directory of the\nversion you want to remove. You can find the directory of a particular\nNode version with the `nodenv prefix` command, e.g. `nodenv prefix\n0.8.22`.\n\nThe [node-build][] plugin provides an `nodenv uninstall` command to\nautomate the removal process.\n\n### Uninstalling nodenv\n\nThe simplicity of nodenv makes it easy to temporarily disable it, or\nuninstall from the system.\n\n1. To **disable** nodenv managing your Node versions, simply remove the\n  `nodenv init` line from your shell startup configuration. This will\n  remove nodenv shims directory from `$PATH`, and future invocations like\n  `node` will execute the system Node version, as before nodenv.\n\n   While disabled, `nodenv` will still be accessible on the command line, but your Node\n  apps won't be affected by version switching.\n\n2. To completely **uninstall** nodenv, perform step (1) and then remove\n   its root directory. This will **delete all Node versions** that were\n   installed under `` `nodenv root`/versions/ `` directory:\n\n        rm -rf `nodenv root`\n\n   If you've installed nodenv using a package manager, as a final step\n   perform the nodenv package removal:\n   - Homebrew: `brew uninstall nodenv`\n   - Archlinux and its derivatives: `sudo pacman -R nodenv`\n\n## Command Reference\n\nLike `git`, the `nodenv` command delegates to subcommands based on its\nfirst argument. The most common subcommands are:\n\n### nodenv local\n\nSets a local application-specific Node version by writing the version\nname to a `.node-version` file in the current directory. This version\noverrides the global version, and can be overridden itself by setting\nthe `NODENV_VERSION` environment variable or with the `nodenv shell`\ncommand.\n\n    nodenv local 0.10.0\n\nWhen run without a version number, `nodenv local` reports the currently\nconfigured local version. You can also unset the local version:\n\n    nodenv local --unset\n\n### nodenv global\n\nSets the global version of Node to be used in all shells by writing\nthe version name to the `~/.nodenv/version` file. This version can be\noverridden by an application-specific `.node-version` file, or by\nsetting the `NODENV_VERSION` environment variable.\n\n    nodenv global 0.10.26\n\nThe special version name `system` tells nodenv to use the system Node\n(detected by searching your `$PATH`).\n\nWhen run without a version number, `nodenv global` reports the\ncurrently configured global version.\n\n### nodenv shell\n\nSets a shell-specific Node version by setting the `NODENV_VERSION`\nenvironment variable in your shell. This version overrides\napplication-specific versions and the global version.\n\n    nodenv shell 0.11.11\n\nWhen run without a version number, `nodenv shell` reports the current\nvalue of `NODENV_VERSION`. You can also unset the shell version:\n\n    nodenv shell --unset\n\nNote that you'll need nodenv's shell integration enabled (step 3 of\nthe installation instructions) in order to use this command. If you\nprefer not to use shell integration, you may simply set the\n`NODENV_VERSION` variable yourself:\n\n    export NODENV_VERSION=0.10.26\n\n### nodenv versions\n\nLists all Node versions known to nodenv, and shows an asterisk next to\nthe currently active version.\n\n    $ nodenv versions\n      0.8.22\n      0.9.12\n      * 0.10.0 (set by /Users/will/.nodenv/version)\n\nThis will also list symlinks to specific Node versions inside the `~/.nodenv/versions` or `~/.nodenv/versions/lts` directories.\n\n### nodenv version\n\nDisplays the currently active Node version, along with information on\nhow it was set.\n\n    $ nodenv version\n    0.10.0 (set by /Users/OiNutter/.nodenv/version)\n\n### nodenv rehash\n\nInstalls shims for all Node executables known to nodenv (i.e.,\n`~/.nodenv/versions/*/bin/*` and `~/.nodenv/versions/lts/*/bin/*`). Run this command after you install a new\nversion of Node, or install an npm package that provides an executable binary.\n\n    $ nodenv rehash\n\n_**note:** the [package-rehash plugin][package-rehash-plugin] automatically runs `nodenv rehash` whenever an npm package is installed globally_\n\n### nodenv which\n\nDisplays the full path to the executable that nodenv will invoke when\nyou run the given command.\n\n    $ nodenv which npm\n    /Users/will/.nodenv/versions/0.10.26/bin/npm\n\n### nodenv whence\n\nLists all Node versions with the given command installed.\n\n    $ nodenv whence npm\n    0.10.0\n    0.9.12\n    0.8.22\n\n## Environment variables\n\nYou can affect how nodenv operates with the following settings:\n\nname | default | description\n-----|---------|------------\n`NODENV_VERSION` | | Specifies the Node version to be used.\u003cbr\u003eAlso see [`nodenv shell`](#nodenv-shell)\n`NODENV_ROOT` | `~/.nodenv` | Defines the directory under which Node versions and shims reside.\u003cbr\u003eAlso see `nodenv root`\n`NODENV_DEBUG` | | Outputs debug information.\u003cbr\u003eAlso as: `nodenv --debug \u003csubcommand\u003e`\n`NODENV_HOOK_PATH` | [_see wiki_][hooks] | Colon-separated list of paths searched for nodenv hooks.\n`NODENV_DIR` | `$PWD` | Directory to start searching for `.node-version` files.\n\n## Development\n\nThe nodenv source code is [hosted on\nGitHub](https://github.com/nodenv/nodenv). It's clean, modular,\nand easy to understand, even if you're not a shell hacker.\n\nTests are executed using [Bats](https://github.com/sstephenson/bats):\n\n    $ bats test\n    $ bats test/\u003cfile\u003e.bats\n\nPlease feel free to submit pull requests and file bugs on the [issue\ntracker](https://github.com/nodenv/nodenv/issues).\n\n### Credits\n\nForked from [Sam Stephenson](https://github.com/sstephenson)'s\n[rbenv](https://github.com/rbenv/rbenv) by [Will\nMcKenzie](https://github.com/oinutter) and modified for node.\n\n\n  [hooks]: https://github.com/rbenv/rbenv/wiki/Authoring-plugins#rbenv-hooks\n  [node-build]: https://github.com/nodenv/node-build#readme\n  [nodenv-doctor]: https://github.com/nodenv/nodenv-installer/blob/main/bin/nodenv-doctor\n  [nodenv-installer]: https://github.com/nodenv/nodenv-installer#nodenv-installer\n  [nodenv-update]: https://github.com/charlesbjohnson/nodenv-update\n  [package-rehash-plugin]: https://github.com/nodenv/nodenv-package-rehash\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodenv%2Fnodenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnodenv%2Fnodenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodenv%2Fnodenv/lists"}