This issue is driving me nuts. In vite, my index.html file sits outside of the public folder by default. So I added a _redirects file to the public folder and also tried adding a netlify.toml file.
Neither works. Tried placing both in the root, both in public, one in public and one in root…
NOTHING WORKS:
My netlify.toml file is :
[build]
command = “npm run build”
publish = “/build”
base =“/”
[[redirects]]
from = “/*”
to = “/index.html”
status = 200
And my _redirect is:
/* /index.html 200
Am I missing a step in the deployment process or something?
Extremely frustrating that netlify works fine with create react app but vite completely falls apart at deployment. Can someone help? Thanks
Do you have any data to back that up? Without determining this is a Netlify issue, I think it’s a little unfair to make such a statement. I use Vite and have used it since v1 and never had an issue.
In any case, you have not shared any info about the site, happy to check this further if you share some info.
Vite outputs in dist as far as I know, so that’s a potential problem.
None of the problems you’ve faced so far have anything to do with Netlify, yet you called out Netlify being a problem in your first message. Your current problem is:
I think the problem is fairly self-explanatory, but if not it means your package.json doesn’t have any build command. Looking at the file structure you’ve shared, your files seem to be in the client folder, so maybe you need to set your base directory to client.
If you read the definitions of those values in the documentation it reveals why it hasn’t worked for you:
The main issue being that your project is actually in the client folder.
You should only need to set the Base directory in the Netlify UI as client, at which point Netlify will find the netlify.toml file you have in that folder and proceed with the configuration in that file.
You would obviously need to make sure that configuration is also correct.
When I did exactly @hrishikesh and @dig suggested and it keeps telling me it can’t find the base directory. It will only find the base directory if I leave the netlify settings for base as “/” but modify the toml file only:
I tried with npm run build and it still wont’ find the build script so I changed my toml file and the netifly settings to vite build. It still cannot find the build script
The netlify.toml is normally stored in the root of your site repository.
and then
All paths configured in the netlify.toml should be absolute paths relative to the base directory, which is the root by default (/).
It would appear you are not follow the documentation. As @nathanmartin explained, the solution to your issue is clearly outlined in previous posts and in the documentation.