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

storybook init: Invalid Version: null #22345

Closed
Tracked by #22243
yannbf opened this issue May 2, 2023 · 0 comments · Fixed by #22642
Closed
Tracked by #22243

storybook init: Invalid Version: null #22345

yannbf opened this issue May 2, 2023 · 0 comments · Fixed by #22642
Assignees

Comments

@yannbf
Copy link
Member

yannbf commented May 2, 2023

Error locations:

Suggested work:

The issue occurs as a result of calling semver.coerce(version) to get the version of a package which looks like one of the following scenarios:

{
  "typescript": "*", // wildcard, common in peerDependency field
  "typescript": "workspace:*", // common in monorepos
  "typescript": "latest", // or any other npm tag
}

This issue relates to the fact that we get package versions by reading a package.json file, which might not be a robust solution. Possible solutions to work on would be:

  • Change the way we read package versions by parsing the lock file instead. We could use tools such as nodejs-lockfile-parser for instance.
  • Change the way we read package versions by using package managers commands e.g. yarn why <dep>.
  • Create a wrapper of semver that deals with the scenario of “invalid” versions and falls back to another mechanism to retrieve the package version, or at least provide a better error message.
  • Add error handling around the places where we calculate versions, and gracefully handle the errors if needed (e.g. skip duplicated dependency check rather than crash)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment