"npm start" not working in reactjs if public folder is inside another folder
Asked Answered
R

1

2

I have the following structure in my react project

  --project
      |
      --main
         |
         -- public
             |
              -- index.html
         -- src
             |
              -- index.js
         webpack.dev.config.js
         webpack.prod.config.js
      -- node_modules
      -- package.json

For the above structure, when I run npm start, I am getting below error

Could not find a required file. Name: index.html Searched in: C:\xampp\htdocs\project\public

because the public folder is there inside main folder. How can I run the code? Please tell me.

EDIT

  output: {
    filename: 'js/[name].js',
    path: path.resolve('/main/public/'),
    publicPath: '/main/public'
  }

tried setting the path in webpack

Rusell answered 26/6, 2018 at 6:41 Comment(4)
You should change the public path in webpack.prod.config.js: github.com/coryhouse/react-slingshot/blob/master/…Virgo
Please check my question. I have updated itRusell
Why only in webpack.prod? Why can't in webpack.dev? Of course I tried both and it's not working.Rusell
@Mr_Perfect did you solve your problem? I"m struggling with the same issue.Coated
V
1

You should change the public path in webpack.prod.config.js: https://github.com/coryhouse/react-slingshot/blob/master/webpack.config.prod.js#L23

Virgo answered 26/6, 2018 at 7:25 Comment(2)
Please tell me what should be the path based on my directory. Because I tried, and it's not working. I think I should setup in webpack.dev.config.jsRusell
Why only in webpack.prod? Why can't in webpack.dev? Of course I tried both and it's not working.Rusell

© 2022 - 2024 — McMap. All rights reserved.