Closed jasonreed7 closed 7 years ago
Can you provide exact commands and browser to run? I installed the project and ran npm start
. No error.
The CommonsChunkPlugin
setup could be left only for production target. I don't see much use for it during development.
I just tried cloning the repo and running npm start
and used Chrome. This time index.html displayed ok but I got this error on another/index.html: Uncaught TypeError: __webpack_require__(...) is not a function. Same results in Firefox. It seems to vary which of the pages I get an error on, but if I go back and forth between index.html and another/index.html I usually end up with an error. I wonder if it might be somehow caching related.
Also I am on node 6.10.2, npm 3.10.10 on Windows 10.
Yeah, I saw the same now. I think the most straight-forward way to fix this is to push parts.extractBundles
within productionConfig
. That way CommonsChunkPlugin
won't disturb development.
That works, thanks! I am a little curious why it seems modules are going missing.
That works, thanks! I am a little curious why it seems modules are going missing.
Can you give an example of missing modules?
I'll change the book so that CommonsChunkPlugin
will be development only.
Just referring to the original error message I was getting, when I was debugging, modules[moduleId] was undefined when it got to certain moduleIds. Maybe the index was wrong or outdated.
But everything does seem to be working now with parts.extractBundles in productionConfig. Thanks for the help!
I'm working through the book and just finished the output- multiple pages-injecting different scripts per page section and I am having a problem. My code is at https://github.com/jasonreed7/webpack-course/ (up to commit 26a2ed...). When I run the dev server and go to localhost:8080/index.html, I get "Uncaught TypeError: Cannot read property 'call' of undefined" on this line:
modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
when moduleId is 135. After that the page does not display.
When I go to localhost:8080/another/ it shows up fine. Googling around I saw someone else getting the same error message and it turned out to be something with CommonsChunkPlugin (issue here: https://github.com/webpack/webpack/issues/1081). So i commented out the parts.extractBundles section of webpack.config.js and both pages worked, although it may have just been coincidence. Not sure if I copied something wrong or if there is an issue here?
Also there seems to be inconsistency. If I remove the `import react;' in index.js it will start working, but another/index.js will get the error that was previously on index.js. This continues even when I put 'import react' back in, until I restart the nodemon.