2

When trying to port a project from webpack-isomorphic-tools to universal-webpack I ran into a strange issue resolving module dependencies.

It seems modules in node_modules, src/js and src/js/constants/* get resolved. But I get the infamous "cannot resolve module" error on modules that are in any other directories at the same level as constants. I can't find anything that changes how webpack should treat src/js/constants`

The project's webpack config and part of the tree of src/js:

https://gist.github.com/bbss/ffebfaa6bbd9fa1d8e6f6c6842e4add5

I'm not sure how to approach debugging this so any pointers would be appreciated.

bbs
  • 1,874
  • 1
  • 17
  • 17
  • Can you say which modules can't be resolved? Are they also in `src/js`? And where is your webpack config relative to this tree? – jal Nov 22 '16 at 10:38
  • The modules that can't be resolved are for example in `src/js/actions`. The webpack configuration is in `webpack/webpack.config.js`. – bbs Nov 22 '16 at 11:02
  • According to docs you want to use [resolve.modulesDirecotries](http://webpack.github.io/docs/configuration.html#resolve-modulesdirectories) to have a hierarchical search within the given directory (__not path__) and its ancestores. To add individual directories to be searched you may want to use [resolve.root](http://webpack.github.io/docs/configuration.html#resolve-root) with an absolute path to the directory. For example `resolve { root: path.resolve('../src/js') } Please give it a try. – jal Nov 22 '16 at 11:44
  • Thanks for the suggestion. Trying to change the resolve.root didn't seem to have an effect. I am using resolve.modulesDirectories, removing for example node_modules from there makes the node_modules not resolve so that is actually working, and if I remove `src/js` then `constants` can not be resolved anymore so that -should- be working too. But for example `actions` in the same level of hierarchy does not work. Really confusing. – bbs Nov 23 '16 at 04:43

0 Answers0