Title: By using `npm add` to add the pkg, the esm project cannot import the functions of pkg by name, but it can do so using the file protocol. · Issue #56286 · nodejs/node · GitHub
Open Graph Title: By using `npm add` to add the pkg, the esm project cannot import the functions of pkg by name, but it can do so using the file protocol. · Issue #56286 · nodejs/node
X Title: By using `npm add` to add the pkg, the esm project cannot import the functions of pkg by name, but it can do so using the file protocol. · Issue #56286 · nodejs/node
Description: Version v22.9.0 Platform Darwin Mac-mini.local 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:36:26 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8103 arm64 Subsystem No response What steps will reproduce the bug? related repo https...
Open Graph Description: Version v22.9.0 Platform Darwin Mac-mini.local 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:36:26 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8103 arm64 Subsystem No response What steps wi...
X Description: Version v22.9.0 Platform Darwin Mac-mini.local 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:36:26 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8103 arm64 Subsystem No response What steps wi...
Opengraph URL: https://github.com/nodejs/node/issues/56286
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"By using `npm add` to add the pkg, the esm project cannot import the functions of pkg by name, but it can do so using the file protocol.","articleBody":"### Version\n\nv22.9.0\n\n### Platform\n\n```text\nDarwin Mac-mini.local 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:36:26 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8103 arm64\n```\n\n### Subsystem\n\n_No response_\n\n### What steps will reproduce the bug?\n\nrelated repo https://github.com/Callidon/bloom-filters\n\nWhen I added this bloom-filters CJS package to my ESM project, I could not import the named functions of this package by name, and could only use the default import.\n\nsteps for reproduction:\n1. this is reproduction code: [bloom-filters.zip](https://github.com/user-attachments/files/18164380/bloom-filters.zip)\n2. Enter the `demo_test` directory and execute `yarn` to install dependencies. At this time, `bloom-filters` is pulled in by `npm`.\n3. When you run `node index.js`, you'll notice that all the named functions exported by the package are located on the default object except for the MinHash method.\n\u003cimg width=\"655\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/4c47227a-2ce2-470b-8443-54ec3ace15cd\" />\n\n4. Now, let's import the bloom-filter as a file protocol. \n\u003cimg width=\"804\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/9691d8e0-94e2-4579-960a-2e74bf94f242\" />\n\n5. Then run `node index.js`\n\n\n6. As shown in the figure above, all named functions in `bloom-filter` have appeared on the module object and default object.\n\n\n### How often does it reproduce? Is there a required condition?\n\nAlways\n\n### What is the expected behavior? Why is that the expected behavior?\n\nMy expectation is that the `bloom-filter` pulled from npm can also import named functions.\nJust like what is said in the document https://nodejs.org/docs/latest-v22.x/api/esm.html#commonjs-namespaces\n\n### What do you see instead?\n\nAs I have described.\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/shlroland","@type":"Person","name":"shlroland"},"datePublished":"2024-12-17T11:18:32Z","url":"https://github.com/nodejs/node/issues/56286"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bc7c3fd4-fc40-2d7a-4350-eafb1caf7ea0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D28:AC748:10ACED9:15A6B0D:6B053293 |
| html-safe-nonce | 68378126101e696763bdd4535cbd9ab026592bb1b2e4479fc06d6d8a1dba69b3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDI4OkFDNzQ4OjEwQUNFRDk6MTVBNkIwRDo2QjA1MzI5MyIsInZpc2l0b3JfaWQiOiIyNDA5MDAxMDI1ODc4MTc2NDAzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f2d0e3752be1f46b627d5a3af71095e896bd847aae46e27b7c79017ddecdb619 |
| hovercard-subject-tag | issue:2744656334 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/56286/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c1ea7a7774467f35689f338c2b7f97772c7ead7028d3cf5b7eda31d6be59664f/nodejs/node/issues/56286 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c1ea7a7774467f35689f338c2b7f97772c7ead7028d3cf5b7eda31d6be59664f/nodejs/node/issues/56286 |
| og:image:alt | Version v22.9.0 Platform Darwin Mac-mini.local 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:36:26 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8103 arm64 Subsystem No response What steps wi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | shlroland |
| hostname | github.com |
| expected-hostname | github.com |
| None | 854d880890b5e847b3fce9d1b31f032107baeddeebad2aa379c48aa4f1451f6b |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 220e980097d94ce616d5d11fbd5316d208e3fc93 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width