{"id":19372119,"url":"https://github.com/nodenv/nodenv-package-rehash","last_synced_at":"2025-04-23T16:31:51.335Z","repository":{"id":57131604,"uuid":"38127332","full_name":"nodenv/nodenv-package-rehash","owner":"nodenv","description":"Never run `nodenv rehash` again","archived":false,"fork":false,"pushed_at":"2019-01-26T20:09:17.000Z","size":113,"stargazers_count":42,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-27T08:06:52.500Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-26T18:34:37.000Z","updated_at":"2023-11-02T21:35:46.000Z","dependencies_parsed_at":"2022-09-01T00:10:55.113Z","dependency_job_id":null,"html_url":"https://github.com/nodenv/nodenv-package-rehash","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodenv%2Fnodenv-package-rehash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodenv%2Fnodenv-package-rehash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodenv%2Fnodenv-package-rehash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodenv%2Fnodenv-package-rehash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nodenv","download_url":"https://codeload.github.com/nodenv/nodenv-package-rehash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223412086,"owners_count":17141261,"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":[],"created_at":"2024-11-10T08:21:40.893Z","updated_at":"2024-11-10T08:21:41.646Z","avatar_url":"https://github.com/nodenv.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/nodenv/nodenv-package-rehash.svg?branch=master)](https://travis-ci.org/nodenv/nodenv-package-rehash)\n\n# nodenv-package-rehash\n\n**Never run `nodenv rehash` again.** \n\nThis nodenv plugin automatically\nruns `nodenv rehash` every time you install or uninstall a global package.\n\n\u003c!-- toc --\u003e\n\n- [Installation](#installation)\n  * [install via git *(recommended)*](#install-via-git-recommended)\n  * [install via homebrew](#install-via-homebrew)\n  * [install via npm](#install-via-npm)\n- [Configuration *(optional)*](#configuration-optional)\n- [Usage](#usage)\n  * [Subcommands](#subcommands)\n- [How It Works](#how-it-works)\n- [Caveats](#caveats)\n- [Credits](#credits)\n\n\u003c!-- tocstop --\u003e\n\n## Installation\n\nAfter installation, you should have a `nodenv package-hooks` subcommand,\nand the package-rehash hook should be included in the output of\n`nodenv hooks install`.\n\nThen you may install the hooks for your existing nodenv versions.\n(This will be done automatically for any node you install henceforth.)\n\n  ```sh\n  nodenv package-hooks install --all\n  ```\n\n### install via git *(recommended)*\n\nInstall the plugin:\n\n  ```sh\n  git clone https://github.com/nodenv/nodenv-package-rehash.git \"$(nodenv root)\"/plugins/nodenv-package-rehash\n  ```\n\n### install via homebrew\n\n  ```sh\n  brew install nodenv/nodenv/nodenv-package-rehash\n  ```\n\n### install via npm\n\n  ```sh\n  npm i -g @nodenv/nodenv-package-rehash\n  ```\n\nThis method is not recommended, because of the likelihood that the nodenv plugin gets installed under a node being _managed_ by nodenv.\nIf using this method, it is highly recommended to install the plugin into your `system` node.\n\nAlso note, this package requires a package level npm postinstall hook to ensure the nodenv-install hook is found by `nodenv hooks install`.\nIf you install this package with lifecycle hooks disabled, you will need to do this manually either by a one-time symlink:\n\n  ```sh\n  ln -s \"$(npm -g prefix)/lib/node_modules/@nodenv/nodenv-package-rehash/etc/nodenv.d/install/install-pkg-hooks.bash\" \"$(nodenv root)/nodenv.d/install/package-rehash.bash\n  ```\n\nor by configuring `NODENV_HOOK_PATH` in your shell startup:\n\n  ```sh\n  export NODENV_HOOK_PATH=$(npm -g prefix)/lib/node_modules/@nodenv/nodenv-package-rehash/etc/nodenv.d/:$NODENV_HOOK_PATH\n  ```\n\n## Configuration *(optional)*\n\nWith this plugin, rehashing will happen on-demand (when global npm modules are installed/uninstalled).\nYou can take advantage of this and remove nodenv's _automatic_ hashing upon [shell initialization][].\nIn your shell startup file (`.bash_profile`, `.bashrc`, or `.zshrc`), add the `--no-rehash` flag to the `nodenv init -` invocation:\n\n  ```sh\n  eval \"$(nodenv init - --no-rehash)\"\n  ```\n\nThis will speed up your shell initialization since nodenv will no longer need to rehash on every startup.\n\n## Usage\n\n1. `npm install -g` a package that provides executables.\n2. Marvel at how you no longer need to type `nodenv rehash`.\n\n### Subcommands\n\nThree sub commands are available for manual hook management.\n\n1. `nodenv package-hooks list [ --all | \u003cversion-name\u003e... ]`\n\n    Lists any hooks installed for the given version(s)\n\n2. `nodenv package-hooks install [ --all | \u003cversion-name\u003e... ]`\n\n    Installs postinstall/postuninstall rehash hooks for the given version(s)\n\n3. `nodenv package-hooks uninstall [ --all | \u003cversion-name\u003e... ]`\n\n    Uninstalls postinstall/postuninstall rehash hooks for the given version(s)\n\nAll three sub commands accept similar arguments:\n\n1. no arg: applies the command only to the currently active node version\n2. version-name: a whitespace-separate list of 1 or more explicit versions (e.g. 0.10.24)\n3. `--all`: applies the command to all installed versions\n\n\n## How It Works\n\nnodenv-package-rehash consists of two parts:\nan npm postinstall (and postuninstall) hook script and a nodenv plugin.\n\nThe npm script hooks into npm's `postinstall` and `postuninstall` lifecycle events\n(corresponding to `npm install -g` and `npm uninstall -g`) to run `nodenv rehash`,\nensuring newly installed package executables are visible to nodenv.\n\nThe nodenv plugin is responsible for installing the npm hook script.\nIt relies on nodenv's `install` hook to copy the npm hook script into node's global `node_modules/.hooks/`.\n\nFor users who install this plugin via npm, there is also a package postinstall hook\nwhich will install the nodenv-install hook into the `NODENV_HOOK_PATH`.\n\n## Caveats\n\nAutomatic rehashing after installation of global packages does _not_ work with versions of npm `^5.1.0 || ~6.0.1`.\nIf you use one of the affected versions of npm,\nyou will need to run `nodenv rehash` manually after installing global packages.\nIt is recommended to upgrade to a version of npm 6.1.0 or later (or stay on a version prior to 5.1.0).\n\nnpm version 5.1.0 [broke global package hooks][issue] ([npm/cli@e084987][npm-cli]) and they remained broken until 6.1.0 ([npm/npm-lifecycle#13][npm-lifecycle]).\nNode versions 8.2.0 through 10.2.1 (inclusive) ship with affected versions of npm.\n\n## Credits\n\nInspired by [Joshua Peek][]'s [rbenv-gem-rehash][].\n\n[Joshua Peek]: https://github.com/josh\n[shell initialization]: https://github.com/nodenv/nodenv#how-nodenv-hooks-into-your-shell\n[rbenv-gem-rehash]: https://github.com/rbenv/rbenv-gem-rehash\n[issue]: https://npm.community/t/npm-version-5-broke-local-and-global-lifecycle-hooks/4857\n[npm-cli]: https://github.com/npm/cli/commit/e084987\n[npm-lifecycle]: https://github.com/npm/npm-lifecycle/pull/13\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodenv%2Fnodenv-package-rehash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnodenv%2Fnodenv-package-rehash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodenv%2Fnodenv-package-rehash/lists"}