Hello,
Im trying to set up react-storybook in a project that I'm working on. They are using better-npm-run with custom NODE_PATH, so what I tried is setting up the same way react-storybook:
"betterScripts": {
"storybook": {
"command": "start-storybook -p 9001",
"env": {
"NODE_PATH": "./src"
}
}
}
But storybook is not picking up the new path like:
I have a component:
project/src/components/MyComponent.js
is importing
import Bar from 'components/Others/Bar';
and I got
ERROR in ./src/components/MyComponent.js
Module not found: Error: Cannot resolve module 'components/Others/Bar' ...
looking for modules in /Users/msaglietto/Projects/project/node_modules
/Users/msaglietto/Projects/project/node_modules/components doesn't exist (module as directory)
Is something that prevent me to use the custom NODE_PATH? or should I configure it elsewhere?
Hey @mnmtanish, thanks it worked. I used:
resolve: {
root: [
path.resolve(__dirname, '../src'),
]
}
or path.resolve(__dirname, '..', process.env.NODE_PATH) if you want to keep using the NODE_PATH
Most helpful comment
Hey @mnmtanish, thanks it worked. I used:
or
path.resolve(__dirname, '..', process.env.NODE_PATH)if you want to keep using the NODE_PATH