storybook: Ember: Uncaught TypeError: _global.window.require is not a function
After running the storybook server, the following error pops up in the browser console:
Uncaught TypeError: _global.window.require is not a function
Originates from this line.
To Reproduce Steps to reproduce the behavior:
- ember new storybook-test --yarn
- cd storybook-test
- npx -p @storybook/cli sb init
- yarn build && yarn storybook
System:
- OS: Ubuntu 16.04 LTS
- Browser: Chrome, Firefox
- Framework: Ember (3.5)
- Version: 4.0.12
- Node: 10.14.1
- Yarn: 1.12.3
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 26 (10 by maintainers)
Commits related to this issue
- feat: storybook initial setup Neede to run ember & storybook enable to local env [issue4957](https://github.com/storybookjs/storybook/issues/4957) Co-Authored-By: Andres Cuervo <acwervo@gmail.com> — committed to movableink/fluid by nicksteffens 2 years ago
- feat: Storybook Documentation Neede to run ember & storybook enable to local env [issue4957](https://github.com/storybookjs/storybook/issues/4957) This effort migrated all docfy documenation to stor... — committed to movableink/fluid by nicksteffens 2 years ago
- feat: storybook documentation Neede to run ember & storybook enable to local env [issue4957](https://github.com/storybookjs/storybook/issues/4957) This effort migrated all docfy documenation to stor... — committed to movableink/fluid by nicksteffens 2 years ago
- feat: storybook documentation Neede to run ember & storybook enable to local env [issue4957](https://github.com/storybookjs/storybook/issues/4957) This effort migrated all docfy documenation to stor... — committed to movableink/fluid by nicksteffens 2 years ago
I ran into this same issue. I ran the exact steps listed in the original issue.
I resolved it by doing the following:
ember install @storybook/ember-cli-storybooknpm run build-storybook && npm run storybookI keep running into this issues.
I have tried to do the following in succession:
ember install @storybook/ember-cli-storybookember buildbuild-storybook -s distember servein one terminalstart-storybook -p 9003 -s distin anotherBut I keep running into:
_global.window.require is not a functionThe file
.storybook/preview-head.htmlis there.It seems that the step missing from the guide is to manually install
ember-cli-storybook. The guides sayBut I don’t think there’s anything that’s actually installing that addon when running
npm i --save-dev @storybook/ember. This addon is what’s responsible for creating the.storybook/preview-head.htmlfile which is crucial to running Stoybook.After manually installing that addon with
ember install ember-cli-storybook, my Ember app is successfully running Storybook.Edit: It also seems that if you run the
storybookscript first, which doesember serve & start-storybook -p 9001 -s dist, the storybook files are not generated. You must first run thebuild-storybookcommand, which doesember build && build-storybook -p 9001 -s dist. After you do that, running thestorybookcommand will update the files, but it seems like it doesn’t create the files initially.here is clean repository with this issue https://github.com/killabeat/storybook-issue-4957
Possibly, or in the auto-generated
scripts. The most possible cause for this problem is, when storybook is started before ember is started. That said, there are other reasons this error is showing up, such as wrong wiring of dist files that sb is not picking up.I think, there are two use-cases:
If this is the decision, we can drive this forward.
Still having this issue. Anyone find a resolution?
@gabrielcsapo Yes I tried and I encountered this error #4672.