-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
[Bug]: Invariant failed: Expected package.json#version to be defined in the "undefined" package} #28606
Comments
** Disclaimer** This information might be inaccurate, due to it being generated automatically
import { readPackageJson } from './utils/package-json';
const packageJson = readPackageJson(dirname);
const version = packageJson.version;
if (!version) {
throw new Error(`Invariant failed: Expected package.json#version to be defined in the "${dirname}" package`);
}
import fs from 'fs';
import path from 'path';
export function readPackageJson(dirname: string) {
const packageJsonPath = path.join(dirname, 'package.json');
if (!fs.existsSync(packageJsonPath)) {
throw new Error(`package.json not found in ${dirname}`);
}
return JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
}
|
@bakervos Sorry for the hassle! It seems like we've broken the |
@shilman just a note to add, this only happens when serving Storybook (start command), |
@bakervos @dgonzalezr As a workaround, you might also try adding the |
Is there any workaround? Facing this issue after doing nx migration. |
+1 |
I am facing this same issue while upgrading my storybook in nx |
I'm waiting for the solution too 🙏 |
+1 facing the same issue when upgrading Storybook in my NX monorepo. |
+1 I have the same error. All dependencies of storybook have the same version. |
Also seeing this issue, looking forward to a fix |
@ilhamsa1 and @christopher-drifte if you want to get storybook running in the meantime try removing the storybook target on your "storybook": {
"executor": "@nx/storybook:storybook",
"options": {
"port": 4402,
"configDir": "libs/component-lib/.storybook"
},
"configurations": {
"ci": {
"quiet": true
}
}
} if your project doesn't already have it defined, go to the {
// other config definitions
"plugins": [ // this might be defined already. if so, just add storybook to the list if its not there.
{
"plugin": "@nx/storybook/plugin",
"options": {
"serveStorybookTargetName": "storybook", // <-- this is the the command that you are running
"buildStorybookTargetName": "build-storybook",
"testStorybookTargetName": "test-storybook",
"staticStorybookTargetName": "static-storybook"
}
},
// other plugins
]
} |
Am using Storybook 8.2.7 and am still facing this issue apparently; EDIT: just noticed the fix was merged 3 days ago; and the release isnt out yet |
Describe the bug
While upgrading my project from storybook 7 to 8, I noticed that serving does not work any more, with the following error:
It looks like this change was made incorrectly, as the package.json's content should be read, instead of fetching the dirname.
Reproduction link
https://example.com/there-is-no-reproduction
Reproduction steps
No response
System
Additional context
This NX Issue is related: nrwl/nx#26914
The text was updated successfully, but these errors were encountered: