Why Does My Webpack Dev Setup Show “Cannot GET /”?

0
8
Asked By Crafter1024 On

I'm having trouble with my Webpack setup. I'm using version 5.99.6, the latest one from NPM, and it seems there's a config issue. I have three configuration files: dev, common, and production, which you can check out on my GitHub [here](https://github.com/simalaia/odinTemplate).

The main issue is that Webpack isn't creating the `dist` directory, which I think is preventing the server from serving any content. Even when I manually create the `dist` folder, it doesn't get populated. I'm stuck because I'm not seeing any error messages that might help me debug. Can anyone offer some advice or insights into what might be going wrong?

3 Answers

Answered By TechieTina24 On

Could you explain what you're expecting Webpack to do for your project? If you're mainly working with HTML, CSS, and JavaScript, you might not even need it for development. Simplifying your setup could help you get going faster!

Crafter1024 -

I think you're right! I just want to learn Webpack properly, even though I’m not building a fully-fledged website yet.

Answered By WebpackWiz85 On

Just to clarify, the `dist` folder is typically used for production builds, so when you're running your app locally during development, the setup may not require it to be populated at all. Make sure you understand the difference between development and production environments in your config.

Crafter1024 -

Thanks for clarifying! I guess my confusion stems from trying to understand Webpack better. I’m getting there!

Answered By CoderDude99 On

It sounds like you've got a classic case of misconfigured Webpack. You might want to double-check what commands you're actually running. For example, running `npm run build` should create and populate the `dist` folder, but it seems like you’re running `npm run dev` instead, which serves your files from the `src` directly. That won’t create the `dist` folder at all. Try running `npm run build` first to see if that fixes the issue!

HelpfulHarry56 -

Right! Don't forget to check your `package.json` scripts too, just to make sure everything’s set up as expected.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.