I'm using create-react-app. I want to run my code from nested directory/sub-directory. My directory structure is as per the screenshot.

I'm using npm start command to run it localy.
I have update my package.json file like
"homepage": "/foobar/"
and my index file
ReactDOM.render(
<Router basename={'foobar'}>
<div id="wrapper">
<RouteList />
</div>
</Router>,
document.getElementById('root')
);
for the routing plugin - link I have included node_modules into both directory for the testing purpose.
but still I'm getting below error while trying to run npm start from the root directory.
Could not find a required file.
Name: index.html
Searched in: C:\git\AccountManager\public
It's working fine from the inner folder. Any idea on how to solve this?
You could change directory to foobar first run npm start. I would incorporate that in my npm start command so that it now looks like the following:
package.json
{
...
"scripts" : {
"start": "cd foobar && react-scripts start",
...
}
}
So far I managed to make it work only if I move only index.html to public folder in the root, or by installing all React node-modules under src folder
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With