{"id":17579037,"url":"https://github.com/mlms13/shim-bug","last_synced_at":"2025-10-05T07:47:04.846Z","repository":{"id":17542519,"uuid":"20345254","full_name":"mlms13/shim-bug","owner":"mlms13","description":null,"archived":false,"fork":false,"pushed_at":"2014-05-31T14:50:46.000Z","size":168,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-07T03:05:58.517Z","etag":null,"topics":[],"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/mlms13.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":"2014-05-30T23:25:21.000Z","updated_at":"2014-05-31T14:50:47.000Z","dependencies_parsed_at":"2022-08-22T23:21:01.930Z","dependency_job_id":null,"html_url":"https://github.com/mlms13/shim-bug","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mlms13/shim-bug","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlms13%2Fshim-bug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlms13%2Fshim-bug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlms13%2Fshim-bug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlms13%2Fshim-bug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mlms13","download_url":"https://codeload.github.com/mlms13/shim-bug/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlms13%2Fshim-bug/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278425499,"owners_count":25984686,"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-05T02:00:06.059Z","response_time":54,"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":[],"created_at":"2024-10-22T00:43:24.024Z","updated_at":"2025-10-05T07:47:04.794Z","avatar_url":"https://github.com/mlms13.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A bug in [browserify-shim](https://github.com/thlorenz/browserify-shim)?\n\nWhen you use browserify-shim to make a library available globally -- let's say jQuery -- the global library isn't available inside the node_modules folder for modules that contain their own package.json.\n\nFor example, given the following structure (which is pretty close to the structure if this repo):\n\n```\nnode_modules/\n    foo/\n       index.js\n       package.json\napp.js\njquery.js\npackage.json\n```\nAssume that inside the main `./package.json` we have browserify and browserify-shim set up as follows:\n\n```\n\"browser\": {\n  \"jquery\": \"./assets/jquery.js\"\n},\n\"browserify\": {\n  \"transform\": [\"browserify-shim\"]\n},\n\"browserify-shim\": {\n  \"jquery\": \"$\"\n}\n```\n\nYou would expect `require('jquery')` to just work, thanks to the shim.  And it does, inside `app.js`.  But if `app.js` requires `foo` (which lives inside the node_modules folder), and `foo` includes a `require('jquery')`, browserify won't use the globally shimmed `jquery`.\n\nIf you remove `node_modules/foo/package.json`, browserify will complete successfully. But as soon as the `foo` module has its own `package.json`, it loses access to the shimmed `jquery`.\n\n## To test\n\nClone this repository:\n\n`git clone https://github.com/mlms13/shim-bug.git`\n\nInstall dependencies (browserify and browserify-shim)\n\n`npm install`\n\nWith browserify installed globally, try to run the following:\n\n`browserify index.js -o bundle.js`\n\nYou should see an error along the lines of `Error: module \"jquery\" not found from \"/Users/\u003cusername\u003e/Projects/shim-bug/node_modules/foo/index.js\"`\n\nIf you delete `node_modules/foo/package.json` and re-run the `browserify` command, everything should work as expected.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlms13%2Fshim-bug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmlms13%2Fshim-bug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlms13%2Fshim-bug/lists"}