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

deno install can't find package npm:storybook-solidjs-vite, unless version is specified #25813

Closed
birkskyum opened this issue Sep 22, 2024 · 1 comment · Fixed by #25858
Closed
Assignees
Labels
bug Something isn't working correctly high priority
Milestone

Comments

@birkskyum
Copy link
Contributor

birkskyum commented Sep 22, 2024

deno 2.0.0-rc.4+0cb00a6

https://www.npmjs.com/package/storybook-solidjs-vite

If a version isn't provided, it doesn't install latest like i'd expect it to, but says the module was not found.

➜ deno i npm:storybook-solidjs-vite
error: npm:storybook-solidjs-vite was not found.

➜ deno i npm:[email protected]
Add npm:[email protected]

➜ deno i npm:storybook-solidjs-vite@latest      
Add npm:[email protected]
Screenshot 2024-09-23 at 01 26 00
@bartlomieju bartlomieju added bug Something isn't working correctly high priority labels Sep 22, 2024
@bartlomieju bartlomieju added this to the 2.0.0 milestone Sep 22, 2024
@marvinhagemeister
Copy link
Contributor

marvinhagemeister commented Sep 23, 2024

Spent a bit debugging this:

The registry data looks like this:

{
  "name": "storybook-solidjs-vite",
  "dist-tags": {
    "latest": "1.0.0-beta.2"
  },
  "versions": {
    "1.0.0-beta.1": {
      // ...
    },
    "1.0.0-beta.2": {
      // ...
    }
  },
  "time": {
    "created": "2023-02-07T00:42:30.776Z",
    "1.0.0-beta.1": "2023-02-07T00:42:31.050Z",
    "modified": "2023-03-25T00:35:53.536Z",
    "1.0.0-beta.2": "2023-03-25T00:35:53.380Z"
  },
  // ...
}

We parse the package requirement as npm:storybook-solidjs-vite@* and then fail the semver comparison check here

.find(|v| req.version_req.tag().is_none() && req.version_req.matches(v))

According to the npm docs the npm install command will always default to the latest tag if no version or tag requirement is specified, see https://docs.npmjs.com/cli/v10/commands/npm-install#description . There apparently is an option to configure that in npm, but I've never heard of anyone changing that, so we can probably ignore that.

But npm also allows you to do npm install foo@* which is different from npm install foo (= npm install foo@latest).

I think this issue uncovers two different bugs in our npm installation logic:

  1. Our semver version comparison seems to ignore pre-release version when matching with *
  2. We don't default to adding @latest when no version or tag is specified for npm packages.

That means both of these commands fail at the moment:

  1. deno i npm:storybook-solidjs-vite
  2. deno i 'npm:storybook-solidjs-vite@*'

nathanwhit added a commit that referenced this issue Sep 25, 2024
…dd npm:pkg` (#25858)

Fixes #25813.

I initially tried doing this in `deno_semver`, where it's a cleaner
change, but that caused breakage in deno in places where we don't expect
a tag (see #25857).

This does not fix wildcard requirements failing to choose pre-release
versions. That's a little more involved and I'll do a separate PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly high priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants