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" },
Solution:
use serve dist ... instead since vite builds into a folder called dist
Jump to solution
11 Replies
Percy
Percy12mo ago
Project ID: e6b14601-7b29-4d0d-af69-40fa8db9da30
SunkCapital
SunkCapital12mo ago
e6b14601-7b29-4d0d-af69-40fa8db9da30
Solution
Brody
Brody12mo ago
use serve dist ... instead since vite builds into a folder called dist
SunkCapital
SunkCapital12mo ago
"start": "serve dist-s -n -L -p $PORT" Like this?
Brody
Brody12mo ago
yeah that looks right
SunkCapital
SunkCapital12mo ago
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.
Brody
Brody12mo ago
you absolutely do want dist in your .gitignore please put it back into .gitignore, and then delete it from the repo
SunkCapital
SunkCapital12mo ago
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
Brody
Brody12mo ago
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
SunkCapital
SunkCapital12mo ago
I see. Thanks
Brody
Brody12mo ago
no problem! happy to help