Loading modules from subdirectories of assets/js/
Closed this issue · 1 comments
An error of "Could not load module" is thrown when my app.js file tries to import from files in subdirectories of assets/js/. The full line of the error:
Processing of js/app.js failed. Error: Could not load module './components/Something' from '/tmp/build_a1b2c3da3caa70b06872f08019710b7d/assets/js'. Make sure the file actually exists.
The offending line of code is import Something from "./components/Something"
.
I'm using brunch, and the error is thrown during brunch build --production
.
If I only import from files in the same directory as app.js and comment out imports from subdirectories, the brunch build works fine.
After further diagnosis, I believe the problem was a namespace collision in brunch with "js/components". Changing the name of the folder fixed the problem.
Conclusion: don't make a folder under js/ called "components".