-
Notifications
You must be signed in to change notification settings - Fork 5
Storybook not resolving __dirname path #387
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
Comments
The lack of the double underscore global values for filename and dirname likely means that the |
@jpandersen87 thanks for flagging this. FYA: I submitted this PR that should resolve it according to Node documentation. |
## Ticket Resolves #387 ## Changes <!-- What was added, updated, or removed in this PR. --> - Updated .storybook/main.js => .storybook/main.mjs based on ECMAScript Modules instead of CommonJS - **.storybook/main.mjs:** ``` path.resolve(import.meta.dirname, "../next.config.js") ``` ## Context for reviewers <!-- Testing instructions, background context, more in-depth details of the implementation, and anything else you'd like to call out or ask reviewers. --> Originally made an update to Storybook in #388 meant to address #387. Making these changes caused issues in [platform-test-nextjs](https://github.com/navapbc/platform-test-nextjs/actions/runs/13999633004/job/39317883628). The steps taken to resolve are in this [PR](navapbc/platform-test-nextjs#98). ## Testing <!-- Provide evidence that the code works as expected. Explain what was done for testing and the results of the test plan. Include screenshots, [GIF demos](https://getkap.co/), shell commands or output to help show the changes working as expected. ProTip: you can drag and drop or paste images into this textbox. --> Making this change in platform-test-nextjs resulted in a successful app build (save for a vulnerability scan). This change also follows [Node.js documentation](https://nodejs.org/docs/latest/api/esm.html#no-__filename-or-__dirname) on what they recommend to use in place of `__dirname`.
What happened?
It appears that Storybook is having issues with resolving the
__dirname
path in the nextConfigPath variable. This is happening when attempting to run thenpm run storybook
command to run Storybook in dev. The problem appears to be coming from themain.js
file in the Storybook setup: template/{{app_name}}/.storybook/main.js.This issue appears resolved when the code below is added to the top of our
main.js
file. However, I'm still unsure of the root cause.Steps to reproduce
From the
{{ APP_NAME }}
directory, run thenpm run storybook
command from the terminal.What browsers are you seeing the problem on?
Chrome
Relevant log output
The text was updated successfully, but these errors were encountered: