npm WARN config production Use `--omit=dev`
I am trying to deploy my project but I get this error which is causing a 404, altough the build is said to be successfully deployed. I tried googling around but could not find a solution to this. The project is using React Vite.
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"dev": "vite",
"build": "vite build",
"lint": "eslint src --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"start": "serve build -s -n -L -p $PORT"
},
11 Replies
Project ID:
e6b14601-7b29-4d0d-af69-40fa8db9da30
e6b14601-7b29-4d0d-af69-40fa8db9da30
Solution
use
serve dist ...
instead since vite builds into a folder called dist
"start": "serve dist-s -n -L -p $PORT"
Like this?
yeah that looks right
Nope, the warning is still there. But the project is deployed now so all good! Also, didn't notice that dist was added to git ignore by default and I had to remove it.
you absolutely do want dist in your .gitignore
please put it back into .gitignore, and then delete it from the repo
It is working now. May I ask why I shouldn't include build in my project. On another react project I can't seem to make things work without uploading the build
you want railway to generate the dist folder itself so that on every deploy your app is rebuilt, this dist folder is created when railway runs the build script in your package.json, if you do include the dist folder in your repo (please don't) you can run into a whole bunch of cryptic errors like file permission errors
I see. Thanks
no problem! happy to help