-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package #28752
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
So I updated another monorepo we recently built to Nx 19.5.3 and Storybook 8.2.6. Storybook starts up just fine without the fix:
After comparing both monorepos with each other, I finally found what was different between them! The older monorepo (that has the storybook issue) defines the storybook script in the "storybook": {
"executor": "@nx/storybook:storybook",
"options": {
"port": 4402,
"configDir": "libs/component-lib/.storybook"
},
"configurations": {
"ci": {
"quiet": true
}
}
}, The newer monorepo defines the storybook script as part of the plugins in "plugins": [
{
"plugin": "@nx/storybook/plugin",
"options": {
"serveStorybookTargetName": "storybook",
"buildStorybookTargetName": "build-storybook",
"testStorybookTargetName": "test-storybook",
"staticStorybookTargetName": "static-storybook"
}
},
] I removed the storybook definition from the older monorepo When using the storybook script from the plugin, a node_modules folder is created in the project with storybook defined. I'm assuming thats why storybook doesn't throw an error. ps: |
@abcdmku Just tried this out myself and it does indeed work! 🎉 Thanks for the info! |
☁️ Nx Cloud ReportCI is running/has finished running commands for commit a65743e. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
I'm releasing a canary release of this PR now. @abcdmku the PR description will automatically get updated. |
Just got around to testing this, sorry for the delay this ticket isn't in my teams sprint 😅 To make sure everything was still failing I ran storybook on that same monorepo:
Installed the canary release
It took a second to get NX happy with a 0.0.0 version of storybook because of the less than v7 check*. After solving that I ran storybook and:
🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉 *edit: I created an issue here for the canary version error here: nrwl/nx#27277 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings
whoops the ui shifted and i clicked the wrong button 😂 didnt mean to close the pr |
@ndelangen lmk if you want me to do anything else for this PR |
Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package (cherry picked from commit be429a7)
Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package (cherry picked from commit be429a7)
Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package (cherry picked from commit be429a7)
Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package (cherry picked from commit be429a7)
Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package (cherry picked from commit be429a7)
Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package (cherry picked from commit be429a7)
Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package (cherry picked from commit be429a7)
Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package (cherry picked from commit be429a7)
Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package (cherry picked from commit be429a7)
Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package (cherry picked from commit be429a7)
Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package (cherry picked from commit be429a7)
Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package (cherry picked from commit be429a7)
Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package (cherry picked from commit be429a7)
Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package (cherry picked from commit be429a7)
Closes #28606
What I did
It looks like the packageJson const was getting set as the path rather than returning the json. I renamed that const and used it to read the file contents and parse the json.
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This pull request has been released as version
0.0.0-pr-28752-sha-a65743e5
. Try it out in a new sandbox by runningnpx storybook@0.0.0-pr-28752-sha-a65743e5 sandbox
or in an existing project withnpx storybook@0.0.0-pr-28752-sha-a65743e5 upgrade
.More information
0.0.0-pr-28752-sha-a65743e5
issue-28606-fix
a65743e5
1722350195
)To request a new release of this pull request, mention the
@storybookjs/core
team.core team members can create a new canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=28752
Greptile Summary
The pull request fixes an issue with the
packageJson
constant instandalone.ts
, ensuring the correct JSON content is read and parsed.code/core/src/core-server/standalone.ts
to correctly read and parsepackage.json
.packageJsonDir
to hold the directory path.packageJson
contains the actual JSON content, resolving the undefined package version error.