-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
utility.assert is not a function #17458
Comments
I had to eject from |
Having the exact same issue... |
I ended up disabling the ...
{
name: '@storybook/addon-essentials',
options: {
docs: false,
},
}, This isn't a fix or workaround. It's just a way to get rid of the error by disabling the add-on as described in docs. |
Same issue, thanks for the fix! |
The workaround isn't great, of course; this means TypeScript projects lose all automatic The root cause seem to be a bug in Doctrine, which reached end of life and stopped releasing in 2018. |
we found this issue happened when upgrading NextJs in our monorepo to the latest 12.1.x version. @shilman the workaround of disabling docs is not a real workaround, as docs is a core feature of storybook. we are now either faced with the choice of not being able to upgrade Next or not have documentation of our components |
update: the Next upgrade removed |
This is a great catch by @dontsave, and I can confirm it resolves our issue as well. Transitive dependency |
I think #17978 is possibly related, too. |
alternatively, you can add a fallback to the webpackFinal config function and provide a polyfill. In this case, you can add the commonjs-assert package.
Then add a property to the webpack final config in main.js const path = require('path');
const toPath = (filePath) => path.join(process.cwd(), filePath);
...
module.exports = {
webpackFinal: async (config) => ({
...config,
resolve: {
...config.resolve,
// can likely be removed in storybook > 6.4 see - https://github.com/storybookjs/storybook/issues/17458
fallback: {
...config.resolve.fallback,
'assert': toPath('commonjs-assert')
}
},
})
} |
@jonesmac, there are no commonjs-assert now, error An unexpected error occurred: "https://registry.yarnpkg.com/commonjs-assert: Not found". |
If you look at the read me for that project's repo, you have to install it with |
For anyone else seeing this issue, you can also use assert: require.resolve('assert'), |
assert: require.resolve('assert'), Thanks, module |
For what is worth, I had the same issue using
Why I have that resolution?
Why that resolution "breaks" my storybook?
so, when I forced How did I fix it?
|
@csantos1113 thats a bit puzzling though. Did you have some kind of override of the webpack config ala @ChrisSargent's comment? Because reading the source code, (in 6.5) we alias Perhaps if you run storybook with
Fair enough, this issue is well and truly resolved in SB7. |
Hey @tmeasday thanks for the quick response.
Looking forward to using SB7 💪
Yes I do, I have this in my
but worth to mention: removing any of that has no effect on the
I ran it but I see the same
I'm not experienced with SB source code, but I notice that:
and
Shouldn't perhaps |
this also fixed my issue (without having to install ===================================================================
diff --git a/.storybook/main.js b/.storybook/main.js
--- a/.storybook/main.js (revision 7050f86b92bd1e869fd6ced97210edfb680b2aa5)
+++ b/.storybook/main.js (date 1664977245522)
@@ -65,7 +65,11 @@
plugins: [
...(config.resolve.plugins || []),
new TsconfigPathsPlugin({ extensions: config.resolve.extensions })
- ]
+ ],
+ fallback: {
+ ...config.resolve.fallback,
+ assert: require.resolve('browser-assert')
+ }
};
return config;
}
===================================================================
diff --git a/package.json b/package.json
--- a/package.json (revision 7050f86b92bd1e869fd6ced97210edfb680b2aa5)
+++ b/package.json (date 1664977254003)
@@ -40,7 +40,6 @@
"@types/node": "18.8.0",
"@types/rimraf": "3.0.2",
"@types/testing-library__jest-dom": "5.14.5",
- "assert": "2.0.0",
"babel-loader": "8.2.5",
"commitizen": "4.2.5",
"cz-conventional-changelog": "3.3.0", |
Funny you mention that @csantos1113 #19341 (comment) So this issue will be fixed in 7.0. @shilman / @ndelangen should we patch this back to 6.5? (#19358) |
FWIW I just |
Updating all storybook modules to |
Hmm, I don't think so @jamsinclair: storybook/lib/builder-webpack5/src/preview/base-webpack.config.ts Lines 89 to 91 in a56e6bd
But I am glad to hear the problem is fixed. Which builder (wp4 vs wp5?) |
In any case going to close this as it is fixed in 7.0. Please try upgrading if you are still seeing problems! |
Ah interesting! @tmeasday It was with WP5 that also might have been the reason. I guess we'll look into 7.0 if it happens again. Thanks for the update! 🙇 |
I actually just pulled the latest for Storybook (6.5.16) and it still happens for me. I had to modify the webpack(v5) config and install browser-assert for it to work as it looks like the |
I used yarn v3 and got the same error(Error: Cannot parse JSDoc tags.). |
@shilman do we have confirmation this is an issue in 7.0? |
A user with a custom webpack config (that overrode |
@ndelangen I get similar issue with react-vite framework after upgrade to v7. All worked well in 6.5. |
@TrySound Can you supply a reproduction please? |
No custom config except viteFinal with export conditions extension. Storybook should not apply hacks while bundling own modules on user side. That doctrine package should be prebundled otherwise it continue to break from time to time. I was able to reproduce only in webstudio big monorepo. Thought will require time to reproduce. The release brings a lot of changes. |
What do we do that you'd consider 'hacks'? |
Replacing assert with browser-assert when user run storybook. Like here unexpected node_modules layout breaks it. |
ok, so here:
and here:
and here:
You think it'd be better if storybook didn't do this at all? What is an "unexpected node_modules layout"? |
Honestly not sure. The layout is built by pnpm in hoisted mode. assert goes to top level node_modules and for some reason becomes preferred over browser-assert. I can investigate this later. Thanks for links. |
Just ran into this problem using SB7 and module.exports = {
stories: [],
addons: ['@storybook/addon-essentials'],
framework: {
name: '@storybook/react-webpack5',
options: {},
},
docs: {
autodocs: true,
},
} And after: module.exports = {
stories: [],
addons: ['@storybook/addon-essentials'],
webpackFinal: (config) => ({
...config,
resolve: {
...config.resolve,
fallback: {
...config.resolve.fallback,
assert: require.resolve('browser-assert'),
},
},
}),
framework: {
name: '@storybook/react-webpack5',
options: {},
},
docs: {
autodocs: true,
},
} I'm quite new to storybook, and am in the process of upgrading from 6.5 to 7. I don't really understand why this change fixes the issue, and don't have a minimal reproduction of the issue to share. Sorry I can't be more helpful, just wanted to voice that upgrading to SB7 does not seem to have completely resolved the problem. |
FWIW, in my case, now on SBv7, the issue is no longer a problem. |
Describe the bug
Storybook fails to build throwing the following errors:
TypeError: utility.assert is not a function
Error loading story index:
Error: Cannot parse JSDoc tags.
System
System:
OS: macOS 12.0.1
CPU: (8) x64 Apple M1
Binaries:
Node: 14.17.5 - ~/.nvm/versions/node/v14.17.5/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 6.14.14 - ~/.nvm/versions/node/v14.17.5/bin/npm
Browsers:
Firefox: 96.0.3
Safari: 15.1
npmPackages:
@storybook/addon-actions: 6.4.18 => 6.4.18
@storybook/addon-docs: 6.4.18 => 6.4.18
@storybook/addon-essentials: 6.4.18 => 6.4.18
@storybook/addon-links: 6.4.18 => 6.4.18
@storybook/addons: ^6.4.18 => 6.4.18
@storybook/builder-webpack5: 6.4.18 => 6.4.18
@storybook/manager-webpack5: 6.4.18 => 6.4.18
@storybook/react: 6.4.18 => 6.4.18
@storybook/testing-react: ^1.2.3 => 1.2.3
The text was updated successfully, but these errors were encountered: