Skip to content
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

storybook does not use NODE_PATH from .env for building code #4496

Closed
vadzim-revolist opened this issue Oct 19, 2018 · 10 comments
Closed

storybook does not use NODE_PATH from .env for building code #4496

vadzim-revolist opened this issue Oct 19, 2018 · 10 comments

Comments

@vadzim-revolist
Copy link

vadzim-revolist commented Oct 19, 2018

After upgrading from 4.0.0-alpha.24 to 4.0.0-rc.1 storybook stopped loading .env file.
I'm using CRA and there is NODE_PATH variable that is needed to compile source.
I've solved the problem by adding env $(cat .env) to the storybook scripts in package.json, but could someone please tell is that a bug or a feature? Will storybook support .env file in the future?
Sorry, I've not found any info in the documentation... (

@igor-dv
Copy link
Member

igor-dv commented Oct 19, 2018

@pksunkara , @ndelangen , could it be related to the recent env loading changes ?

@pksunkara
Copy link
Member

Possibly. But loading from .env is working as we have chromatic based tests for this.

@vadzim-revolist
Copy link
Author

@pksunkara It's weird :(

@vadzim-revolist
Copy link
Author

vadzim-revolist commented Oct 19, 2018

@pksunkara @igor-dv
I've created test repo from scratch
https://github.com/vadzim/test-storybook

  • npx create-react-app test-storybook
  • cd test-storybook
  • npx -p @storybook/cli@rc sb init
  • add .env with NODE_PATH=./src
  • edit App.js to import files from src without './'
  • add App.js to storybook

yarn start works as expected

yarn storybook does not work

env $(cat .env) yarn storybook runs storybook

@ndelangen
Copy link
Member

@vadzim-revolist Have you tried this with anything other then NODE_PATH?

@vadzim-revolist
Copy link
Author

vadzim-revolist commented Oct 23, 2018

@ndelangen I've tried just now.
Actually it reads .env file and passes all the content of it into storybook js, even NODE_PATH, but does not use NODE_PATH from .env to build storybook itself.
If I set NODE_PATH from command line like NODE_PATH=src yarn storybook then it works.

@vadzim-revolist vadzim-revolist changed the title .env support storybook does not use NODE_PATH from .env for building code Oct 23, 2018
@vadzim-revolist
Copy link
Author

vadzim-revolist commented Oct 23, 2018

On rc-3 this error still present

@ndelangen
Copy link
Member

I see.

@ndelangen
Copy link
Member

Thank you for testing, I now understand the problem better.

@pksunkara
Copy link
Member

Related discussion, facebook/create-react-app#2230

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants