Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use npm imports when BYONM is enabled #23267

Closed
redabacha opened this issue Apr 7, 2024 · 6 comments
Closed

Unable to use npm imports when BYONM is enabled #23267

redabacha opened this issue Apr 7, 2024 · 6 comments
Assignees
Labels
needs discussion this topic needs further discussion to determine what action to take node compat node resolution
Milestone

Comments

@redabacha
Copy link

Version: Deno 1.42.1

There are many times where I have one-off dependencies that are used in scripts that would not make sense to include as part of the main project package.json. However when BYONM is enabled, you are unable to use npm: imports anymore and will receive this error message like this if attempting to do so:

error: Could not find a matching package for '...' in '.../package.json'. You must specify this as a package.json dependency when the node_modules folder is not managed by Deno.

This is not the case for JSR and HTTPS imports which continue to work as normal which feels very inconsistent. Having NPM imports continue to function while BYONM is enabled would make mode 3 described in this issue a much more effective and realistic option.

@bartlomieju bartlomieju added needs discussion this topic needs further discussion to determine what action to take node compat 2.0 triage required node resolution labels Apr 7, 2024
@lucacasonato
Copy link
Member

There are 3 possible solutions for this as a user:

  1. add the npm specifier to deno.json or package.json and install into the node_modules.
  2. run the tools script with --node-modules-dir=none. This will cause Deno to use the global resolver for this script, disabling BYONM entirely
  3. install the package by running deno install with your script as an "entrypoint", which will cause it to install any packages that script depends on: deno install -e ./main.ts (this is not yet implemented, but will be before Deno 2.0.

@algoflows

This comment was marked as off-topic.

@lucacasonato

This comment was marked as off-topic.

@algoflows

This comment was marked as off-topic.

@dsherret dsherret added this to the 2.0.0 milestone Sep 3, 2024
@dsherret dsherret self-assigned this Sep 3, 2024
@lucacasonato

This comment was marked as off-topic.

@dsherret
Copy link
Member

dsherret commented Sep 4, 2024

After #25399 , it will now be possible to put these jsr dependencies in the deno.json and run deno install. After that, the npm deps of the JSR dependencies will resolve. There's no way to make this work with other package managers without putting these missing dependencies in a package.json though.

Going to close this one because it's basically done other than #25411 which can be handled there.

@dsherret dsherret closed this as completed Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs discussion this topic needs further discussion to determine what action to take node compat node resolution
Projects
None yet
Development

No branches or pull requests

5 participants