storybook does not use NODE_PATH from .env for building code

Created on 19 Oct 2018  路  10Comments  路  Source: storybookjs/storybook

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... (

babel / webpack question / support

All 10 comments

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

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

@pksunkara It's weird :(

@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

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

@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.

On rc-3 this error still present

I see.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

purplecones picture purplecones  路  3Comments

ZigGreen picture ZigGreen  路  3Comments

shilman picture shilman  路  3Comments

Jonovono picture Jonovono  路  3Comments

sakulstra picture sakulstra  路  3Comments