{"id":18575878,"url":"https://github.com/bevry-archive/lazy-require","last_synced_at":"2025-08-03T06:15:56.740Z","repository":{"id":39638905,"uuid":"10921975","full_name":"bevry-archive/lazy-require","owner":"bevry-archive","description":"Sponsor this project to keep it maintained, or use Deno instead.","archived":false,"fork":false,"pushed_at":"2023-01-23T06:08:54.000Z","size":732,"stargazers_count":17,"open_issues_count":26,"forks_count":4,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-12T22:25:16.828Z","etag":null,"topics":["archived","nodejs","nodejs-modules"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bevry-archive.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["balupton"],"patreon":"bevry","open_collective":"bevry","ko_fi":"balupton","liberapay":"bevry","custom":["https://bevry.me/fund"]}},"created_at":"2013-06-24T22:29:30.000Z","updated_at":"2022-10-25T15:13:27.000Z","dependencies_parsed_at":"2023-02-05T02:46:25.290Z","dependency_job_id":null,"html_url":"https://github.com/bevry-archive/lazy-require","commit_stats":null,"previous_names":["bevry/lazy-require"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/bevry-archive/lazy-require","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bevry-archive%2Flazy-require","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bevry-archive%2Flazy-require/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bevry-archive%2Flazy-require/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bevry-archive%2Flazy-require/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bevry-archive","download_url":"https://codeload.github.com/bevry-archive/lazy-require/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bevry-archive%2Flazy-require/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268500896,"owners_count":24260239,"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","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["archived","nodejs","nodejs-modules"],"created_at":"2024-11-06T23:22:38.970Z","updated_at":"2025-08-03T06:15:56.502Z","avatar_url":"https://github.com/bevry-archive.png","language":"JavaScript","funding_links":["https://github.com/sponsors/balupton","https://patreon.com/bevry","https://opencollective.com/bevry","https://ko-fi.com/balupton","https://liberapay.com/bevry","https://bevry.me/fund","https://buymeacoffee.com/balupton"],"categories":[],"sub_categories":[],"readme":"\u003c!-- TITLE/ --\u003e\n\n\u003ch1\u003eLazy Require\u003c/h1\u003e\n\n\u003c!-- /TITLE --\u003e\n\n\n\u003c!-- BADGES/ --\u003e\n\n\u003cspan class=\"badge-travisci\"\u003e\u003ca href=\"http://travis-ci.com/bevry/lazy-require\" title=\"Check this project's build status on TravisCI\"\u003e\u003cimg src=\"https://img.shields.io/travis/com/bevry/lazy-require/master.svg\" alt=\"Travis CI Build Status\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-npmversion\"\u003e\u003ca href=\"https://npmjs.org/package/lazy-require\" title=\"View this project on NPM\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/lazy-require.svg\" alt=\"NPM version\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-npmdownloads\"\u003e\u003ca href=\"https://npmjs.org/package/lazy-require\" title=\"View this project on NPM\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/lazy-require.svg\" alt=\"NPM downloads\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-daviddm\"\u003e\u003ca href=\"https://david-dm.org/bevry/lazy-require\" title=\"View the status of this project's dependencies on DavidDM\"\u003e\u003cimg src=\"https://img.shields.io/david/bevry/lazy-require.svg\" alt=\"Dependency Status\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-daviddmdev\"\u003e\u003ca href=\"https://david-dm.org/bevry/lazy-require#info=devDependencies\" title=\"View the status of this project's development dependencies on DavidDM\"\u003e\u003cimg src=\"https://img.shields.io/david/dev/bevry/lazy-require.svg\" alt=\"Dev Dependency Status\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cbr class=\"badge-separator\" /\u003e\n\u003cspan class=\"badge-githubsponsors\"\u003e\u003ca href=\"https://github.com/sponsors/balupton\" title=\"Donate to this project using GitHub Sponsors\"\u003e\u003cimg src=\"https://img.shields.io/badge/github-donate-yellow.svg\" alt=\"GitHub Sponsors donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-patreon\"\u003e\u003ca href=\"https://patreon.com/bevry\" title=\"Donate to this project using Patreon\"\u003e\u003cimg src=\"https://img.shields.io/badge/patreon-donate-yellow.svg\" alt=\"Patreon donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-flattr\"\u003e\u003ca href=\"https://flattr.com/profile/balupton\" title=\"Donate to this project using Flattr\"\u003e\u003cimg src=\"https://img.shields.io/badge/flattr-donate-yellow.svg\" alt=\"Flattr donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-liberapay\"\u003e\u003ca href=\"https://liberapay.com/bevry\" title=\"Donate to this project using Liberapay\"\u003e\u003cimg src=\"https://img.shields.io/badge/liberapay-donate-yellow.svg\" alt=\"Liberapay donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-buymeacoffee\"\u003e\u003ca href=\"https://buymeacoffee.com/balupton\" title=\"Donate to this project using Buy Me A Coffee\"\u003e\u003cimg src=\"https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg\" alt=\"Buy Me A Coffee donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-opencollective\"\u003e\u003ca href=\"https://opencollective.com/bevry\" title=\"Donate to this project using Open Collective\"\u003e\u003cimg src=\"https://img.shields.io/badge/open%20collective-donate-yellow.svg\" alt=\"Open Collective donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-crypto\"\u003e\u003ca href=\"https://bevry.me/crypto\" title=\"Donate to this project using Cryptocurrency\"\u003e\u003cimg src=\"https://img.shields.io/badge/crypto-donate-yellow.svg\" alt=\"crypto donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-paypal\"\u003e\u003ca href=\"https://bevry.me/paypal\" title=\"Donate to this project using Paypal\"\u003e\u003cimg src=\"https://img.shields.io/badge/paypal-donate-yellow.svg\" alt=\"PayPal donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-wishlist\"\u003e\u003ca href=\"https://bevry.me/wishlist\" title=\"Buy an item on our wishlist for us\"\u003e\u003cimg src=\"https://img.shields.io/badge/wishlist-donate-yellow.svg\" alt=\"Wishlist browse button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\n\u003c!-- /BADGES --\u003e\n\n\n\u003c!-- DESCRIPTION/ --\u003e\n\nLazy require allows you to require modules lazily, meaning that when you lazy require a module that is missing, lazy require will automatically install it for you.\n\n\u003c!-- /DESCRIPTION --\u003e\n\n\n## Usage\n\n```javascript\n// Import\nvar lazyRequire = require('lazy-require')\n\n// Attempt to load the module `ambi`, if it doesn't exist, then try to install it and load it again\n// Do this synchronously, only available in Node 0.12 and above\n// Passing a callback as the 3rd argument will do this asynchronously, available in all node versions\nvar ambi = lazyRequire('ambi', {\n    /* options */\n})\nif (ambi instanceof Error) {\n    // Error ....\n    console.log('ambi failed to load because of:', ambi.stack)\n} else {\n    // Success ...\n}\n\n// Attempt to load the module `ambi`, if it doesn't exist, then try to install it and load it again\n// Do this synchronously but with a callback, only available in Node 0.12 and above\nlazyRequire.sync(\n    'ambi',\n    {\n        /* options */\n    },\n    function (err, ambi) {\n        // Error ...\n        if (err)\n            return console.log('ambi failed to load because of:', err.stack)\n\n        // Success ...\n    }\n)\n\n// Attempt to load the module `ambi`, if it doesn't exist, then try to install it and load it again\n// Do this asynchronously, available in all node versions\nlazyRequire.async(\n    'ambi',\n    {\n        /* options */\n    },\n    function (err, ambi) {\n        // Error ...\n        if (err)\n            return console.log('ambi failed to load because of:', err.stack)\n\n        // Success ...\n    }\n)\n\n// Attempt to load the module `ambi`, if it doesn't exist, then try to install it and load it again\n// Do this synchronously if supported (Node 0.12 and above), otherwise do it asynchronously\nlazyRequire.auto(\n    'ambi',\n    {\n        /* options */\n    },\n    function (err, ambi) {\n        // Error ...\n        if (err)\n            return console.log('ambi failed to load because of:', err.stack)\n\n        // Success ...\n    }\n)\n```\n\nThe following options are supported:\n\n-   `cwd` the module path that you would like the requested package to be installed to if it doesn't exist, always recommended\n-   `save` if the requested package doesn't exist, would you like to do a `npm --save` for it to add it to your `cwd`'s `package.json` dependencies?\n\nThere's some other methods also available to you, for now, read the source to discover them.\n\n\u003c!-- INSTALL/ --\u003e\n\n\u003ch2\u003eInstall\u003c/h2\u003e\n\n\u003ca href=\"https://npmjs.com\" title=\"npm is a package manager for javascript\"\u003e\u003ch3\u003enpm\u003c/h3\u003e\u003c/a\u003e\n\u003cul\u003e\n\u003cli\u003eInstall: \u003ccode\u003enpm install --save lazy-require\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003eImport: \u003ccode\u003eimport * as pkg from ('lazy-require')\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003eRequire: \u003ccode\u003econst pkg = require('lazy-require')\u003c/code\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003ca href=\"https://jspm.io\" title=\"Native ES Modules CDN\"\u003e\u003ch3\u003ejspm\u003c/h3\u003e\u003c/a\u003e\n\n``` html\n\u003cscript type=\"module\"\u003e\n    import * as pkg from '//dev.jspm.io/lazy-require@4.6.0'\n\u003c/script\u003e\n```\n\n\u003ch3\u003e\u003ca href=\"https://editions.bevry.me\" title=\"Editions are the best way to produce and consume packages you care about.\"\u003eEditions\u003c/a\u003e\u003c/h3\u003e\n\n\u003cp\u003eThis package is published with the following editions:\u003c/p\u003e\n\n\u003cul\u003e\u003cli\u003e\u003ccode\u003elazy-require\u003c/code\u003e aliases \u003ccode\u003elazy-require/source/index.js\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003elazy-require/source/index.js\u003c/code\u003e is \u003ca href=\"https://en.wikipedia.org/wiki/ECMAScript#ES.Next\" title=\"ECMAScript Next\"\u003eESNext\u003c/a\u003e source code for \u003ca href=\"https://nodejs.org\" title=\"Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine\"\u003eNode.js\u003c/a\u003e with \u003ca href=\"https://nodejs.org/dist/latest-v5.x/docs/api/modules.html\" title=\"Node/CJS Modules\"\u003eRequire\u003c/a\u003e for modules\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003elazy-require/edition-browsers/index.js\u003c/code\u003e is \u003ca href=\"https://en.wikipedia.org/wiki/ECMAScript#ES.Next\" title=\"ECMAScript Next\"\u003eESNext\u003c/a\u003e compiled for web browsers with \u003ca href=\"https://nodejs.org/dist/latest-v5.x/docs/api/modules.html\" title=\"Node/CJS Modules\"\u003eRequire\u003c/a\u003e for modules\u003c/li\u003e\u003c/ul\u003e\n\n\u003c!-- /INSTALL --\u003e\n\n\n\u003c!-- HISTORY/ --\u003e\n\n\u003ch2\u003eHistory\u003c/h2\u003e\n\n\u003ca href=\"https://github.com/bevry/lazy-require/blob/master/HISTORY.md#files\"\u003eDiscover the release history by heading on over to the \u003ccode\u003eHISTORY.md\u003c/code\u003e file.\u003c/a\u003e\n\n\u003c!-- /HISTORY --\u003e\n\n\n\u003c!-- CONTRIBUTE/ --\u003e\n\n\u003ch2\u003eContribute\u003c/h2\u003e\n\n\u003ca href=\"https://github.com/bevry/lazy-require/blob/master/CONTRIBUTING.md#files\"\u003eDiscover how you can contribute by heading on over to the \u003ccode\u003eCONTRIBUTING.md\u003c/code\u003e file.\u003c/a\u003e\n\n\u003c!-- /CONTRIBUTE --\u003e\n\n\n\u003c!-- BACKERS/ --\u003e\n\n\u003ch2\u003eBackers\u003c/h2\u003e\n\n\u003ch3\u003eMaintainers\u003c/h3\u003e\n\nThese amazing people are maintaining this project:\n\n\u003cul\u003e\u003cli\u003e\u003ca href=\"https://github.com/balupton\"\u003eBenjamin Lupton\u003c/a\u003e — \u003ca href=\"https://github.com/bevry/lazy-require/commits?author=balupton\" title=\"View the GitHub contributions of Benjamin Lupton on repository bevry/lazy-require\"\u003eview contributions\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\n\u003ch3\u003eSponsors\u003c/h3\u003e\n\nNo sponsors yet! Will you be the first?\n\n\u003cspan class=\"badge-githubsponsors\"\u003e\u003ca href=\"https://github.com/sponsors/balupton\" title=\"Donate to this project using GitHub Sponsors\"\u003e\u003cimg src=\"https://img.shields.io/badge/github-donate-yellow.svg\" alt=\"GitHub Sponsors donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-patreon\"\u003e\u003ca href=\"https://patreon.com/bevry\" title=\"Donate to this project using Patreon\"\u003e\u003cimg src=\"https://img.shields.io/badge/patreon-donate-yellow.svg\" alt=\"Patreon donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-flattr\"\u003e\u003ca href=\"https://flattr.com/profile/balupton\" title=\"Donate to this project using Flattr\"\u003e\u003cimg src=\"https://img.shields.io/badge/flattr-donate-yellow.svg\" alt=\"Flattr donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-liberapay\"\u003e\u003ca href=\"https://liberapay.com/bevry\" title=\"Donate to this project using Liberapay\"\u003e\u003cimg src=\"https://img.shields.io/badge/liberapay-donate-yellow.svg\" alt=\"Liberapay donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-buymeacoffee\"\u003e\u003ca href=\"https://buymeacoffee.com/balupton\" title=\"Donate to this project using Buy Me A Coffee\"\u003e\u003cimg src=\"https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg\" alt=\"Buy Me A Coffee donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-opencollective\"\u003e\u003ca href=\"https://opencollective.com/bevry\" title=\"Donate to this project using Open Collective\"\u003e\u003cimg src=\"https://img.shields.io/badge/open%20collective-donate-yellow.svg\" alt=\"Open Collective donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-crypto\"\u003e\u003ca href=\"https://bevry.me/crypto\" title=\"Donate to this project using Cryptocurrency\"\u003e\u003cimg src=\"https://img.shields.io/badge/crypto-donate-yellow.svg\" alt=\"crypto donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-paypal\"\u003e\u003ca href=\"https://bevry.me/paypal\" title=\"Donate to this project using Paypal\"\u003e\u003cimg src=\"https://img.shields.io/badge/paypal-donate-yellow.svg\" alt=\"PayPal donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-wishlist\"\u003e\u003ca href=\"https://bevry.me/wishlist\" title=\"Buy an item on our wishlist for us\"\u003e\u003cimg src=\"https://img.shields.io/badge/wishlist-donate-yellow.svg\" alt=\"Wishlist browse button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\n\u003ch3\u003eContributors\u003c/h3\u003e\n\nThese amazing people have contributed code to this project:\n\n\u003cul\u003e\u003cli\u003e\u003ca href=\"https://github.com/balupton\"\u003eBenjamin Lupton\u003c/a\u003e — \u003ca href=\"https://github.com/bevry/lazy-require/commits?author=balupton\" title=\"View the GitHub contributions of Benjamin Lupton on repository bevry/lazy-require\"\u003eview contributions\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/RobLoach\"\u003eRob Loach\u003c/a\u003e — \u003ca href=\"https://github.com/bevry/lazy-require/commits?author=RobLoach\" title=\"View the GitHub contributions of Rob Loach on repository bevry/lazy-require\"\u003eview contributions\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\n\u003ca href=\"https://github.com/bevry/lazy-require/blob/master/CONTRIBUTING.md#files\"\u003eDiscover how you can contribute by heading on over to the \u003ccode\u003eCONTRIBUTING.md\u003c/code\u003e file.\u003c/a\u003e\n\n\u003c!-- /BACKERS --\u003e\n\n\n\u003c!-- LICENSE/ --\u003e\n\n\u003ch2\u003eLicense\u003c/h2\u003e\n\nUnless stated otherwise all works are:\n\n\u003cul\u003e\u003cli\u003eCopyright \u0026copy; 2013+ \u003ca href=\"http://bevry.me\"\u003eBevry Pty Ltd\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\nand licensed under:\n\n\u003cul\u003e\u003cli\u003e\u003ca href=\"http://spdx.org/licenses/MIT.html\"\u003eMIT License\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\n\u003c!-- /LICENSE --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbevry-archive%2Flazy-require","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbevry-archive%2Flazy-require","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbevry-archive%2Flazy-require/lists"}