{"id":15286268,"url":"https://github.com/bahmutov/have-it","last_synced_at":"2025-04-13T03:28:38.449Z","repository":{"id":57261798,"uuid":"82394979","full_name":"bahmutov/have-it","owner":"bahmutov","description":"The fastest NPM install does nothing because you already have it","archived":false,"fork":false,"pushed_at":"2017-10-02T21:51:33.000Z","size":187,"stargazers_count":75,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-20T11:47:53.021Z","etag":null,"topics":["install","installer","npm","offline","yarn"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bahmutov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-18T15:13:23.000Z","updated_at":"2024-11-30T05:49:35.000Z","dependencies_parsed_at":"2022-08-25T06:10:59.813Z","dependency_job_id":null,"html_url":"https://github.com/bahmutov/have-it","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fhave-it","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fhave-it/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fhave-it/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fhave-it/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahmutov","download_url":"https://codeload.github.com/bahmutov/have-it/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248659262,"owners_count":21141105,"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":["install","installer","npm","offline","yarn"],"created_at":"2024-09-30T15:11:34.540Z","updated_at":"2025-04-13T03:28:38.423Z","avatar_url":"https://github.com/bahmutov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# have-it\n\n\u003e The fastest NPM install does nothing because you already have it\n\n[![NPM][npm-icon] ][npm-url]\n\n[![Build status][ci-image] ][ci-url]\n[![semantic-release][semantic-image] ][semantic-url]\n[![js-standard-style][standard-image]][standard-url]\n\nIf you have lots of local projects each with its own `node_modules` folder\nyou probably already have a huge number of installed NPM packages. If you\nare offline or hate waiting, you can \"install\" a module from another folder\ninto the current one using dummy \"proxy\" module. The setup is almost instant!\n\nWatch in action: [NPM vs Yarn vs have-it](https://www.youtube.com/watch?v=A0o1kC3d_Co)\n\nQuick stats: installing lodash, debug and express takes NPM 5 seconds,\nyarn takes 3 seconds, and `have-it` takes 250ms (0.25 seconds)\n\n## Example\n\n1. Install `have-it` globally with `npm i -g have-it`. This tool will be\n  available under `have` and `have-it` names.\n\n2. Set root folder for top level search. For example my projects are usually\nin `$HOME/git` folder. Thus I set `export HAVE=$HOME/git`. By default it\nwill use `$HOME` value as the root.\n\n    ```\n    $HOME\n      /git\n        /projectA\n          /node_modules\n        /projectB\n          /node_modules\n        /projectC\n          /node_modules\n    ```\n\n3. Install something with `have \u003cname\u003e`. For example\n\n    ```sh\n    $ time have lodash\n    have-it lodash\n    have 1 module(s)\n    lodash@4.17.4\n\n    real  0m0.240s\n    ```\n\nFor comparison `$ time npm i lodash` prints `real 0m1.909s` - a speed up\nof 10 times!\n\nYou can pass typical NPM flags to save the installed version\n`-S --save -D --save-dev`.\n\n## Installing dependencies from package.json\n\nJust run `have` to install dependencies from the `package.json` file.\n\n## Fallback\n\nIf a module cannot be found locally, `have-it` falls back to using\n`npm install` command.\n\n## How does it work?\n\n`have-it` finds the module already installed and then creates in the local\n`node_modules` folder a dummy file that has `main` pointing at the found\n`main` file. For example, if `lodash` was found in folder\n`/Users/gleb/projectX/node_modules/lodash` the local dummy package will be\n\n```\ncat node_modules/lodash/package.json\n{\n  \"name\": \"lodash\",\n  \"main\": \"/Users/gleb/projectX/node_modules/lodash/lodash.js\",\n  \"version\": \"4.17.4\",\n  \"description\": \"fake module created by 'have-it' pointing at existing module\"\n}\n```\n\nHaving actual dummy module like above works nicely with Node and its\nmodule loader.\n\n## Main features\n\nSeems all use cases are already implemented: installing a specific version,\nsaving version in `package.json`, etc.\n\n* [x] [#8](https://github.com/bahmutov/have-it/issues/8)\n  save installed name version in `package.json`\n* [x] [#9](https://github.com/bahmutov/have-it/issues/9)\n  respect `package.json` versions when installing\n* [x] [#10](https://github.com/bahmutov/have-it/issues/10)\n  allow installing specific version from CLI `have lodash@3.0.0`\n* [x] [#12](https://github.com/bahmutov/have-it/issues/12)\n  make symbolic links for each \"bin\" entry\n\n## Related projects\n\n* [copi](https://github.com/bahmutov/copi) - physically copies found package\n  into this folder\n* [local-npm](https://github.com/nolanlawson/local-npm) - Local and\n  offline-first npm mirror (unmaintained)\n\n## FAQ\n\n\u003cdetails\u003e\n  \u003csummary\u003eWhy not use `npm link`\u003c/summary\u003e\n  \u003cp\u003e`npm link` is cumbersome and links a single package *version* globally\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eWhy not use symbolic links?\u003c/summary\u003e\n  \u003cp\u003eSymbolic links do not work if the linked package needs to load another\n  one of its own packages. For example `debug` requires `ms`. If we\n  link to `debug` package folder, then Node module loader fails to\n  find `ms`\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eWhy not use local NPM proxy?\u003c/summary\u003e\n  \u003cp\u003eBecause it is (relatively) hard\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eWhat happens in production / CI?\u003c/summary\u003e\n  \u003cp\u003eNothing, you just use `npm install` there\u003c/p\u003e\n\u003c/details\u003e\n\n## Debugging\n\nRun this tool with `DEBUG=have-it have ...` environment variable.\n\nTo run [e2e test](test/e2e.sh) use `npm run e2e`\n\nTo avoid building a single \"dist\" file during local development, add\na new alias to the `package.json`\n\n```json\n{\n  \"bin\": {\n    \"have-it\": \"dist/have-it.js\",\n    \"have\": \"dist/have-it.js\",\n    \"_have\": \"bin/_have-it.js\"\n  }\n}\n```\n\nand use this alias for local work\n\n```sh\nnpm link\n_have lodash\n```\n\n### Small print\n\nAuthor: Gleb Bahmutov \u0026lt;gleb.bahmutov@gmail.com\u0026gt; \u0026copy; 2017\n\n* [@bahmutov](https://twitter.com/bahmutov)\n* [glebbahmutov.com](https://glebbahmutov.com)\n* [blog](https://glebbahmutov.com/blog)\n\nLicense: MIT - do anything with the code, but don't blame me if it does not work.\n\nSupport: if you find any problems with this module, email / tweet /\n[open issue](https://github.com/bahmutov/have-it/issues) on Github\n\n## MIT License\n\nCopyright (c) 2017 Gleb Bahmutov \u0026lt;gleb.bahmutov@gmail.com\u0026gt;\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\n[npm-icon]: https://nodei.co/npm/have-it.svg?downloads=true\n[npm-url]: https://npmjs.org/package/have-it\n[ci-image]: https://travis-ci.org/bahmutov/have-it.svg?branch=master\n[ci-url]: https://travis-ci.org/bahmutov/have-it\n[semantic-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\n[semantic-url]: https://github.com/semantic-release/semantic-release\n[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg\n[standard-url]: http://standardjs.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fhave-it","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahmutov%2Fhave-it","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fhave-it/lists"}