a month ago
Build fails when deploying, error says webpack not found but it is installed properly in local development.
this is a MERN stack application, which has 3 package.jsons.
one in the root with the build commands to cd into the frontend and backend directories, and build each accordingly.
Iam fairly new to deployment of MERN stack applications.
I would love some guidance, it would be greatly appreciated. Thank you
[internal] load build definition from Dockerfile
Apr 02 09:44:22
[internal] load build definition from Dockerfile 0ms
Apr 02 09:44:22
[internal] load build definition from Dockerfile
Apr 02 09:44:22
[internal] load build definition from Dockerfile 11ms
Apr 02 09:44:22
[internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1741046653
Apr 02 09:44:22
[internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1741046653 133ms
Apr 02 09:44:22
[internal] load .dockerignore
Apr 02 09:44:22
[internal] load .dockerignore
Apr 02 09:44:22
[internal] load .dockerignore 0ms
Apr 02 09:44:22
[internal] load .dockerignore
Apr 02 09:44:22
[internal] load .dockerignore 8ms
Apr 02 09:44:22
[stage-0 10/10] COPY . /app
Apr 02 09:44:22
[stage-0 9/10] RUN printf '\nPATH=/app/node_modules/.bin:$PATH' >> /root/.profile
Apr 02 09:44:22
[stage-0 8/10] RUN --mount=type=cache,id=s/c60c96f2-0904-459e-9d4e-ad7af0b3b5ec-node_modules/cache,target=/app/node_modules/.cache npm run build
Apr 02 09:44:22
[stage-0 7/10] COPY . /app/.
Apr 02 09:44:22
[stage-0 6/10] RUN --mount=type=cache,id=s/c60c96f2-0904-459e-9d4e-ad7af0b3b5ec-/root/npm,target=/root/.npm npm ci
Apr 02 09:44:22
[stage-0 5/10] COPY . /app/.
Apr 02 09:44:22
[stage-0 4/10] RUN nix-env -if .nixpacks/nixpkgs-ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.nix && nix-collect-garbage -d
Apr 02 09:44:22
[stage-0 3/10] COPY .nixpacks/nixpkgs-ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.nix .nixpacks/nixpkgs-ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.nix
Apr 02 09:44:22
[internal] load build context
Apr 02 09:44:22
[stage-0 2/10] WORKDIR /app/
Apr 02 09:44:22
[stage-0 1/10] FROM ghcr.io/railwayapp/nixpacks:ubuntu-1741046653@sha256:ed406b77fb751927991b8655e76c33a4521c4957c2afeab293be7c63c2a373d2
Apr 02 09:44:22
[stage-0 1/10] FROM ghcr.io/railwayapp/nixpacks:ubuntu-1741046653@sha256:ed406b77fb751927991b8655e76c33a4521c4957c2afeab293be7c63c2a373d2
Apr 02 09:44:22
[internal] load build context
Apr 02 09:44:22
[internal] load build context 0ms
Apr 02 09:44:22
[internal] load build context
Apr 02 09:44:22
[stage-0 1/10] FROM ghcr.io/railwayapp/nixpacks:ubuntu-1741046653@sha256:ed406b77fb751927991b8655e76c33a4521c4957c2afeab293be7c63c2a373d2 7ms
Apr 02 09:44:22
[internal] load build context 97ms
Apr 02 09:44:22
[stage-0 2/10] WORKDIR /app/ 0ms – CACHED
Apr 02 09:44:22
[stage-0 3/10] COPY .nixpacks/nixpkgs-ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.nix .nixpacks/nixpkgs-ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.nix 0ms – CACHED
Apr 02 09:44:22
[stage-0 4/10] RUN nix-env -if .nixpacks/nixpkgs-ffeebf0acf3ae8b29f8c7049cd911b9636efd7e7.nix && nix-collect-garbage -d 0ms – CACHED
Apr 02 09:44:22
[stage-0 5/10] COPY . /app/.
Apr 02 09:44:22
[stage-0 5/10] COPY . /app/. 38ms
Apr 02 09:44:22
[stage-0 6/10] RUN --mount=type=cache,id=s/c60c96f2-0904-459e-9d4e-ad7af0b3b5ec-/root/npm,target=/root/.npm npm ci
Apr 02 09:44:22
npm warn config production Use --omit=dev
instead.
Apr 02 09:44:23
npm warn EBADENGINE Unsupported engine { npm warn EBADENGINE package: 'esbw@1.0.0', npm warn EBADENGINE required: { node: '20.11.1' }, npm warn EBADENGINE current: { node: 'v20.18.1', npm: '10.8.2' } npm warn EBADENGINE }
Apr 02 09:44:24
added 26 packages, and audited 27 packages in 1s
Apr 02 09:44:24
6 packages are looking for funding run npm fund
for details
Apr 02 09:44:24
found 0 vulnerabilities
Apr 02 09:44:24
[stage-0 6/10] RUN --mount=type=cache,id=s/c60c96f2-0904-459e-9d4e-ad7af0b3b5ec-/root/npm,target=/root/.npm npm ci 1s
Apr 02 09:44:24
[stage-0 7/10] COPY . /app/.
Apr 02 09:44:24
[stage-0 7/10] COPY . /app/. 49ms
Apr 02 09:44:24
[stage-0 8/10] RUN --mount=type=cache,id=s/c60c96f2-0904-459e-9d4e-ad7af0b3b5ec-node_modules/cache,target=/app/node_modules/.cache npm run build
Apr 02 09:44:24
npm warn config production Use --omit=dev
instead.
Apr 02 09:44:24
> esbw@1.0.0 build > cd frontend && npm run build
Apr 02 09:44:24
npm warn config production Use --omit=dev
instead.
Apr 02 09:44:24
> frontend@1.0.0 build > webpack --mode production
Apr 02 09:44:24
sh: 1: webpack: not found
3 Replies
a month ago
i have three package.json files.
one at the root:
{
"name": "esbw",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "concurrently \"npm run server\" \"npm run client-watch\"",
"server": "cd backend && npm run build",
"client-watch": "cd frontend && npm run start",
"build": "cd frontend && npm run build"
},
"author": "",
"license": "ISC",
"description": "",
"engines": {
"node": "20.11.1"
},
"devDependencies": {
"concurrently": "^9.1.2"
}
}
one in /frontend
{
"name": "frontend",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "webpack --mode development --watch",
"build": "webpack --mode production"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"animejs": "^3.2.2",
"axios": "^1.8.3",
"bootstrap": "^5.3.3",
"bootstrap-icons": "^1.11.3",
"react": "^19.0.0",
"react-bootstrap": "^2.10.9",
"react-dom": "^19.0.0",
"react-router-dom": "^7.3.0",
"react-spinners": "^0.15.0",
"react-toastify": "^11.0.5",
"swiper": "^11.2.6"
},
"devDependencies": {
"@babel/core": "^7.26.10",
"@babel/preset-env": "^7.26.9",
"@babel/preset-react": "^7.26.3",
"babel-loader": "^10.0.0",
"css-loader": "^7.1.2",
"dotenv-webpack": "^8.1.0",
"html-webpack-plugin": "^5.6.3",
"sass": "^1.85.1",
"sass-loader": "^16.0.5",
"style-loader": "^4.0.0",
"webpack": "^5.98.0",
"webpack-cli": "^6.0.1",
"webpack-dev-server": "^5.2.0"
}
}
and one in /backend.
{
"name": "backend",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "npm ci && node index"
},
"author": "",
"license": "ISC",
"description": "",
"type": "module",
"dependencies": {
"axios": "^1.8.4",
"bcryptjs": "^3.0.2",
"body-parser": "^1.20.3",
"connect-flash": "^0.1.1",
"connect-mongo": "^5.1.0",
"crypto": "^1.0.1",
"discord.js": "^14.18.0",
"dotenv": "^16.4.7",
"elo-js": "^1.0.1",
"elo-rating": "^1.0.1",
"express": "^4.21.2",
"express-handlebars": "^8.0.1",
"express-hbs": "^2.5.0",
"express-session": "^1.18.1",
"ioredis": "^5.6.0",
"moment": "^2.30.1",
"mongoose": "^8.12.1",
"multer": "^1.4.5-lts.1",
"node-cron": "^3.0.3",
"node-fetch": "^3.3.2",
"passport": "^0.7.0",
"passport-local": "^1.0.0",
"request-ip": "^3.3.0",
"screp-js": "^0.3.0",
"screp-js-file": "^0.2.1"
},
"devDependencies": {
"nodemon": "^3.1.9"
}
}
to answer your question, yes webpack is installed and works locally compiling my es6 react front end and using the backend for API calls etc, but iam recieving that error during the build phase of depoloyment.
a month ago
I'm guessing you have one service then and that service simply runs on the root of your repo? The issue with this is I think Railway only installs the package.json dependencies that're listed in the package.json of the root folder
Status changed to Solved dev • 26 days ago