Closed 0xmovses closed 2 years ago
In your webpackFinal
config add:
config.plugins.push(
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
})
);
@EvHaus thanks for this, where would I import the webpack file from in a nextJS 12 project hmmm
fixed by importing const webpack = require("webpack");
Thanks so much.
I tried the same thing. Did not work for me. Nothing in terminal but when storybook starts i get this
If you're using Vite with Storybook then the solution is this:
// vite.config.ts
// Make sure to npm install this first
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
export default defineConfig({
...,
optimizeDeps: {
esbuildOptions: {
plugins: [
NodeGlobalsPolyfillPlugin({
buffer: true,
}),
],
},
},
I tried same thing, but new error shows:
Describe the bug when running story book the builder stops at 99% and in broswer console I have the error
ReferenceError: Buffer is not defined
storybook version
6.4.14
nextjs version12.0.8
Some stories load, but any with this error do not. My guess is I need to set the buffer to something in weback 5 config
The full error is:
my main.js
To Reproduce The repo is public, run yarn, then yarn storybook https://github.com/INFLOWMusic/inflow-app
NB. we are in the process of refactoring stories, some still use the old storiesOf method. This is not causing the issue
System Please paste the results of
npx sb@next info
here.Environment Info:
System: OS: macOS 11.3.1 CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz Binaries: Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node Yarn: 1.21.1 - /usr/local/bin/yarn npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm Browsers: Chrome: 97.0.4692.99 Firefox: 96.0.2 Safari: 14.1 npmPackages: @storybook/addon-actions: ^6.4.14 => 6.4.14 @storybook/addon-essentials: ^6.4.14 => 6.4.14 @storybook/addon-links: ^6.4.14 => 6.4.14 @storybook/builder-webpack5: ^6.4.14 => 6.4.14 @storybook/manager-webpack5: ^6.4.14 => 6.4.14 @storybook/preset-scss: ^1.0.3 => 1.0.3 @storybook/react: ^6.4.14 => 6.4.14
Additional context
our package.json