survivejs / webpack-book

From apprentice to master (CC BY-NC-ND)
https://survivejs.com/webpack/
2.42k stars 319 forks source link

"Uncaught ReferenceError: require is not defined" in the build file #254

Closed nikhammerellis closed 7 years ago

nikhammerellis commented 7 years ago

Noticed this after 5.2 in the book (it likely happened before and I wasn't paying attention), not seeing the Hello World text or proper styling in the browser, webpack seems to build correctly.

In inspect, console tab is saying that "Uncaught ReferenceError: require is not defined" and where its not defined is strange, the app.js file that gets built from webpack.

screen shot 2017-04-08 at 12 49 07 pm

Here is a link to my code up to 5.2 in a repo https://github.com/nikhammerellis/webpack-demo

Everything looks correct but I am new to webpack and this book has been my intro. I already deleted the app.js file and rebuilt it with npm run build and that didn't seem to work.

bebraw commented 7 years ago

@nikhammerellis How did you solve it? I haven't had a look yet. :)

nikhammerellis commented 7 years ago

@bebraw I ran through the beginning of the book (1-4) and repeated the steps in a new project and couldn't reproduce the error. I left out a particular better errors plugin this time. Based on the fact that it is working now, I have to assume I made one or more typos that somehow allowed webpack to compile incorrectly but successfully. That particular codebase is still jacked. I'm going with a freak coding accident for now, will let you know if the problem shows itself again.

bebraw commented 7 years ago

Ok, cool. Feel free to link me to a repo if you ever get it again. 👍