Storybook: Can not resolve modules with absolute path in v4.0.0

Created on 30 Oct 2018  路  5Comments  路  Source: storybookjs/storybook

Describe the bug
I upgraded storybook from version 4.0.0-alpha.25 to v.4.0.0 but i get errors like Module not found: Error: Can't resolve ... for all the modules that i have imported with absolute paths. In the migration guide i don't see any changes regarding absolute paths, am i missing something?

Screenshots
image

System:

  • OS: Windows10
  • Node: 10.7.0
  • Framework: react
  • Addons: actions, viewport, links, knobs
  • Version: 4.0.0

Additional context
I use create-react-app v.2

react question / support

Most helpful comment

Ok,

Btw running storybook with cross-env NODE_PATH=src/ start-storybook -p 9009 -s public it works, but i'd prefer not to have an extra dependency just for this.

Thank you for your time @igor-dv !

All 5 comments

Do you have any custom webpack.config,js ?

@igor-dv no, just plain create-react-app v2 (not ejected) and i have a .env file in the root folder with NODE_PATH=src for absolute imports.

I think it's related to NODE_PATH, and not to the absolute imports.
We have an open issue for this already - #4496, let's continue the discussion there.

Anyway, you can workaround absolut imports by adding the custom webpack.confing.js:

//.storybook/webpack.config.js

module.exports = {
  resolve: {
    modules: ['path to src dir'],
  }
}

Ok,

Btw running storybook with cross-env NODE_PATH=src/ start-storybook -p 9009 -s public it works, but i'd prefer not to have an extra dependency just for this.

Thank you for your time @igor-dv !

馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

purplecones picture purplecones  路  3Comments

wahengchang picture wahengchang  路  3Comments

Jonovono picture Jonovono  路  3Comments

shilman picture shilman  路  3Comments

levithomason picture levithomason  路  3Comments