{"id":31827827,"url":"https://github.com/masotime/require-watch","last_synced_at":"2025-10-11T19:19:02.886Z","repository":{"id":18317654,"uuid":"84005887","full_name":"masotime/require-watch","owner":"masotime","description":"Automatically refresh require dependencies in NodeJS","archived":false,"fork":false,"pushed_at":"2022-12-08T06:27:10.000Z","size":1458,"stargazers_count":3,"open_issues_count":12,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-30T19:51:00.534Z","etag":null,"topics":["dynamic","nodejs","require"],"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/masotime.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-03-05T22:09:13.000Z","updated_at":"2020-04-12T21:40:25.000Z","dependencies_parsed_at":"2022-07-26T21:47:04.212Z","dependency_job_id":null,"html_url":"https://github.com/masotime/require-watch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/masotime/require-watch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masotime%2Frequire-watch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masotime%2Frequire-watch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masotime%2Frequire-watch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masotime%2Frequire-watch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/masotime","download_url":"https://codeload.github.com/masotime/require-watch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masotime%2Frequire-watch/sbom","scorecard":{"id":622936,"data":{"date":"2025-08-11","repo":{"name":"github.com/masotime/require-watch","commit":"82fe530744716d25e9e730737cf101f7fa552f53"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/22 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 8 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"46 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-w5p7-h5w8-2hfq","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-832h-xg76-4gv6","Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-w9mr-4mfr-499f","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T05:35:15.210Z","repository_id":18317654,"created_at":"2025-08-21T05:35:15.210Z","updated_at":"2025-08-21T05:35:15.210Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279008463,"owners_count":26084460,"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-10-11T02:00:06.511Z","response_time":55,"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":["dynamic","nodejs","require"],"created_at":"2025-10-11T19:19:00.776Z","updated_at":"2025-10-11T19:19:02.880Z","avatar_url":"https://github.com/masotime.png","language":"JavaScript","readme":"# require-watch\n\n[![npm downloads][downloads-image]][downloads-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coverage-image]][coverage-url]\n\nRequire watch wraps around Node's module loader and watches files as they are loaded. If a change is detected on a watched module, then that module, along with all its parents, are automatically flushed from the require cache.\n\nThis was primarily motivated in enabling hot reloading for express routes. See below under [Express example](#express-example)\n\nExample usage:\n\n```\nimport watch from 'require-watch';\n\nwatch(require.resolve('lib/some-root'));\n```\n\nAfter this, any changes in `lib/some-root` will automatically flush the require cache. Note that flushing the require cache **still requires code that manually requires the module again**.\n\n## Notes\n\n* You should require and use `require-watch` as early as possible in your application, so that it can properly wrap `Module._load` with its watching mechanisms\n* For verbose output of `require-watch`, set `NODE_DEBUG=require-watch`\n\n## Limitations\n\nAlthough the module is flushed from the require cache, there is no guarantee that it will be reloaded. Calling code is responsible for doing this. For example:\n\n### `index.js`\n\n```\nimport watch from 'require-watch';\nimport sayHello from 'lib/hello';\n\nwatch(require.resolve('lib/hello'));\n\nsetInterval(sayHello, 1000); // this syntax won't be hot reloaded\n```\n\n### `lib/sayHello.js`\n\n```\nexport default function() { console.log('hello'); }\n```\n\nIf you were to edit `lib/sayHello.js`, there would be no effect. **Instead, you need to introduce a require statement in the calling function:**\n\n### `index.js`\n\n```\nsetInterval(() =\u003e require('lib/sayHello')(), 1000); // this syntax enables hot reloading\n```\n\nThis is necessary because this module only flushes the require cache - any existing code loaded in memory remains in memory if it is not re-required. **There is no way around this limitation.**\n\nThe reason why this revised code works is because the caller, `setInterval` is requesting the module every time from the require cache. There should be minimal performance impact because if a module is already loaded, it is not reloaded from disk.\n\n## Express example\n\nIf you originally had some code like this:\n\n```\nimport express from 'express';\n\nconst app = express();\n\napp.get('/', (req, res, next) =\u003e {\n\t// some code you want dynamic\n});\n\napp.listen(8080);\n```\n\nFirst extract the router into a separate file:\n\n```\nimport { Router } from 'express';\n\nconst router = Router();\n\nrouter.get('/', (req, res, next) =\u003e {\n\t// some code you want dynamic\n});\n\nexport default router;\n```\n\nThen update your app entry like this:\n\n```\nimport express from 'express';\nimport watch from 'require-watch'; // use the module\n\nconst app = express();\n\nwatch(require.resolve('./router')); // watch this file\napp.use('/', (req, res, next) =\u003e require('./router')(req, res, next)); // force reloading\n\napp.listen(8080);\n```\n\nWhat happens is that every WEB request causes a fresh REQUIRE request. If you edit `./router.js`, `require-watch` will invalidate the cache, forcing a reload of the module.\n\n[downloads-image]: https://img.shields.io/npm/dm/require-watch.svg?style=flat-square\n[downloads-url]: https://www.npmjs.com/package/require-watch\n[travis-image]: https://travis-ci.org/masotime/require-watch.svg?branch=master\n[travis-url]: https://travis-ci.org/masotime/require-watch\n[daviddm-image]: https://david-dm.org/masotime/require-watch.svg?theme=shields.io\n[daviddm-url]: https://david-dm.org/masotime/require-watch\n[coverage-image]: https://coveralls.io/repos/github/masotime/require-watch/badge.svg?branch=master\n[coverage-url]: https://coveralls.io/github/masotime/require-watch?branch=master","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasotime%2Frequire-watch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasotime%2Frequire-watch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasotime%2Frequire-watch/lists"}