R
Railway•13mo ago
p1gp3n

Cannot deploy Redux

We implemented Redux in our React app and tested locally, then pushed to Railway but the deployment failed with errors related to the new files. We deploy our frontend app often and have not run into other issues, and I'm sure Railway supports Redux, so I'm not sure what's causing this issue. Service ID: f09aff3f-c562-4252-8e56-05531566765f
20 Replies
Percy
Percy•13mo ago
Project ID: f09aff3f-c562-4252-8e56-05531566765f
Brody
Brody•13mo ago
please share your package.json
p1gp3n
p1gp3n•13mo ago
{
"name": "frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"build:staging": "vite build --mode staging",
"start": "serve dist",
"format": "prettier --write ."
},
"dependencies": {
"@auth0/auth0-react": "^2.1.0",
"@chakra-ui/icons": "^2.0.19",
"@chakra-ui/react": "^2.7.0",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@react-spring/web": "^9.7.1",
"dompurify": "^3.0.1",
"dotenv": "^16.0.3",
"framer-motion": "^10.12.16",
"history": "^5.3.0",
"react": "^18.2.0",
"react-device-detect": "^2.2.3",
"react-dom": "^18.2.0",
"react-ga": "^3.3.1",
"react-icons": "^4.8.0",
"react-router-dom": "^6.8.1"
},
"devDependencies": {
"@types/dompurify": "^2.4.0",
"@types/dotenv": "^8.2.0",
"@types/node": "^20.2.1",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@vitejs/plugin-react": "^3.1.0",
"prettier": "^2.8.3",
"typescript": "^4.9.3",
"vite": "^4.1.0"
}
}
{
"name": "frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"build:staging": "vite build --mode staging",
"start": "serve dist",
"format": "prettier --write ."
},
"dependencies": {
"@auth0/auth0-react": "^2.1.0",
"@chakra-ui/icons": "^2.0.19",
"@chakra-ui/react": "^2.7.0",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@react-spring/web": "^9.7.1",
"dompurify": "^3.0.1",
"dotenv": "^16.0.3",
"framer-motion": "^10.12.16",
"history": "^5.3.0",
"react": "^18.2.0",
"react-device-detect": "^2.2.3",
"react-dom": "^18.2.0",
"react-ga": "^3.3.1",
"react-icons": "^4.8.0",
"react-router-dom": "^6.8.1"
},
"devDependencies": {
"@types/dompurify": "^2.4.0",
"@types/dotenv": "^8.2.0",
"@types/node": "^20.2.1",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@vitejs/plugin-react": "^3.1.0",
"prettier": "^2.8.3",
"typescript": "^4.9.3",
"vite": "^4.1.0"
}
}
thanks for taking a look!
Brody
Brody•13mo ago
arent you missing redux in your deps?
p1gp3n
p1gp3n•13mo ago
sorry I may have posted the wrong one. you should see react-redux here.
{
"name": "frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"build:staging": "vite build --mode staging",
"start": "serve dist",
"format": "prettier --write ."
},
"dependencies": {
"@auth0/auth0-react": "^2.1.0",
"@chakra-ui/icons": "^2.0.19",
"@chakra-ui/react": "^2.7.0",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@react-spring/web": "^9.7.1",
"@reduxjs/toolkit": "^1.9.5",
"dompurify": "^3.0.1",
"dotenv": "^16.0.3",
"framer-motion": "^10.12.16",
"history": "^5.3.0",
"react": "^18.2.0",
"react-device-detect": "^2.2.3",
"react-dom": "^18.2.0",
"react-ga": "^3.3.1",
"react-icons": "^4.8.0",
"react-redux": "^8.1.1",
"react-router-dom": "^6.8.1"
},
"devDependencies": {
"@types/dompurify": "^2.4.0",
"@types/dotenv": "^8.2.0",
"@types/node": "^20.2.1",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@vitejs/plugin-react": "^3.1.0",
"prettier": "^2.8.3",
"typescript": "^4.9.3",
"vite": "^4.1.0"
}
}
{
"name": "frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"build:staging": "vite build --mode staging",
"start": "serve dist",
"format": "prettier --write ."
},
"dependencies": {
"@auth0/auth0-react": "^2.1.0",
"@chakra-ui/icons": "^2.0.19",
"@chakra-ui/react": "^2.7.0",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@react-spring/web": "^9.7.1",
"@reduxjs/toolkit": "^1.9.5",
"dompurify": "^3.0.1",
"dotenv": "^16.0.3",
"framer-motion": "^10.12.16",
"history": "^5.3.0",
"react": "^18.2.0",
"react-device-detect": "^2.2.3",
"react-dom": "^18.2.0",
"react-ga": "^3.3.1",
"react-icons": "^4.8.0",
"react-redux": "^8.1.1",
"react-router-dom": "^6.8.1"
},
"devDependencies": {
"@types/dompurify": "^2.4.0",
"@types/dotenv": "^8.2.0",
"@types/node": "^20.2.1",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@vitejs/plugin-react": "^3.1.0",
"prettier": "^2.8.3",
"typescript": "^4.9.3",
"vite": "^4.1.0"
}
}
"redux": "^4.2.1"
"redux": "^4.2.1"
Brody
Brody•13mo ago
are your import paths correct? just because it works on your machine doesn't make it a railway specific problem, I'm sure you've seen those memes
p1gp3n
p1gp3n•13mo ago
yes of course 🙂 ive been deploying many other PRs to railway today. only the redux fails
Brody
Brody•13mo ago
railway uses node 16 by default perhaps what you doing would require you to be on node 18?
p1gp3n
p1gp3n•13mo ago
we use 18 locally. just doing the vanilla install of redux. not sure if you've seen others with this issue? we could try to test locally on 16 (though i'd need to check if other things we do require it). is it possible to use 18? i do have this in my dockerfile: FROM node:18 as build so i just assumed our railway was on 18 but never checked
Brody
Brody•13mo ago
oh you are building with a dockerfile? definitely would have been very useful information to have up front, could you please send it
p1gp3n
p1gp3n•13mo ago
FROM node:18 as build

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

ARG RAILWAY_ENVIRONMENT
ENV RAILWAY_ENVIRONMENT=$RAILWAY_ENVIRONMENT

RUN echo $RAILWAY_ENVIRONMENT

RUN npx vite build --mode $RAILWAY_ENVIRONMENT

FROM node:18

WORKDIR /app

COPY package*.json ./

#RUN npm ci --only=production

COPY --from=build /app/dist ./dist

RUN npm install -g serve

CMD serve -s dist -l tcp://0.0.0.0:$PORT
FROM node:18 as build

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

ARG RAILWAY_ENVIRONMENT
ENV RAILWAY_ENVIRONMENT=$RAILWAY_ENVIRONMENT

RUN echo $RAILWAY_ENVIRONMENT

RUN npx vite build --mode $RAILWAY_ENVIRONMENT

FROM node:18

WORKDIR /app

COPY package*.json ./

#RUN npm ci --only=production

COPY --from=build /app/dist ./dist

RUN npm install -g serve

CMD serve -s dist -l tcp://0.0.0.0:$PORT
apologies for that
Brody
Brody•13mo ago
so I see you have a multistage build, I like that type of optimization, but you should try getting this working with the simplest possible dockerfile and work up from there
p1gp3n
p1gp3n•13mo ago
it has been working for months. and works with other deployments. only when i add redux does it fail
Brody
Brody•13mo ago
is something getting .gitignored that shouldn't be
p1gp3n
p1gp3n•13mo ago
dont think so. i get this error. not using an absolute, just can't find the file
Brody
Brody•13mo ago
that's a pretty funky looking import path if I'm honest
p1gp3n
p1gp3n•13mo ago
let me do some digging. can keep you posted
Brody
Brody•13mo ago
like that might be the correct import path for local development, but you probably need a more platform dependent path
p1gp3n
p1gp3n•13mo ago
ugh. found the issue. nothing to do with Railway or Redux. just a file not referenced correctly. just figured it was something with Redux since everyhting else worked, and the build wasn't failing locally. apologies.
Brody
Brody•13mo ago
haha no worries, glad you've solved it