Next.js application deployment error

I'm trying to deploy my Next.js application on Railway. It's getting this error again and again... How to fix this error
No description
48 Replies
Percy
Percy10mo ago
Project ID: N/A
Fragly
Fragly10mo ago
mind sending full logs using this? https://bookmarklets.up.railway.app/log-downloader/
maddsua
maddsua10mo ago
but I'd bet a can of coke you have package-lock.json gitignored and npm ci just wouldn't work without this file
Vinojan Abhimanyu
I have tried with deleted the package-log file. It's not working
maddsua
maddsua10mo ago
could you share .gitignore and package.json files?
Vinojan Abhimanyu
Yes of course
maddsua
maddsua10mo ago
'cause the only way npm ci command can fail that I can think of is when it wasn't able to find a valid package-lock.json
Vinojan Abhimanyu
{ "name": "gplus-gpa-calculator", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint" }, "dependencies": { "@clerk/nextjs": "^4.29.1", "@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-select": "^2.0.0", "@radix-ui/react-separator": "^1.0.3", "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-toast": "^1.1.5", "@sanity/image-url": "^1.0.2", "@sanity/vision": "^3.23.4", "@supabase/ssr": "^0.0.10", "@supabase/supabase-js": "^2.39.1", "class-variance-authority": "^0.7.0", "clsx": "^2.0.0", "lucide-react": "^0.300.0", "next": "14.0.4", "next-sanity": "^7.0.5", "query-string": "^8.1.0", "react": "^18", "react-dom": "^18", "sanity": "^3.23.4", "styled-components": "^6.1.3", "tailwind-merge": "^2.2.0", "tailwindcss-animate": "^1.0.7" }, "devDependencies": { "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", "autoprefixer": "^10.0.1", "eslint": "^8", "eslint-config-next": "14.0.4", "postcss": "^8", "tailwindcss": "^3.3.0", "typescript": "^5" } } What can I do now?
maddsua
maddsua10mo ago
could you also add .gitignore? just to rule this one out
Vinojan Abhimanyu
Okay sure
Vinojan Abhimanyu
See https://help.github.com/articles/ignoring-files/ for more about ignoring files. dependencies /node_modules /.pnp .pnp.js .yarn/install-state.gz testing /coverage next.js /.next/ /out/ production /build misc .DS_Store .pem debug npm-debug.log yarn-debug.log* yarn-error.log* local env files .env*.local .env vercel .vercel typescript *.tsbuildinfo next-env.d.ts
maddsua
maddsua10mo ago
looks fine to me. ok, my quick guess didn't fly I guess at this point I'd just ask you to send full logs so that we can take a closer look use Fragly's link
Vinojan Abhimanyu
context: 02e4ec0928adb82fc3b5eb2cf141dab2 ╔════════ Nixpacks v1.20.0 ═══════╗ ║ setup │ nodejs_18, npm-9_x ║ ║─────────────────────────────────║ ║ install │ npm ci ║ ║─────────────────────────────────║ ║ build │ npm run build ║ ║─────────────────────────────────║ ║ start │ npm run start ║ ╚═════════════════════════════════╝ #0 building with "default" instance using docker driver #1 [internal] load .dockerignore #1 transferring context: 2B done #1 DONE 0.0s #2 [internal] load build definition from Dockerfile #2 transferring dockerfile: 2.88kB done #2 DONE 0.1s #3 [internal] load metadata for ghcr.io/railwayapp/nixpacks:ubuntu-1702339400 #3 DONE 0.2s #4 [stage-0 1/8] FROM ghcr.io/railwayapp/nixpacks:ubuntu-1702339400@sha256:1a9c1eed040aacf8f898be048210ef2d3366b1228373c4e6818362bb75611b32 #4 DONE 0.0s #5 [internal] load build context #5 transferring context: 1.75MB 0.0s done #5 DONE 0.1s #6 [stage-0 2/8] WORKDIR /app/ #6 CACHED #7 [stage-0 3/10] COPY .nixpacks/nixpkgs-bf744fe90419885eefced41b3e5ae442d732712d.nix .nixpacks/nixpkgs-bf744fe90419885eefced41b3e5ae442d732712d.nix #7 CACHED #8 [stage-0 4/10] RUN nix-env -if .nixpacks/nixpkgs-bf744fe90419885eefced41b3e5ae442d732712d.nix && nix-collect-garbage -d #8 CACHED #9 [stage-0 5/10] COPY . /app/. #9 CACHED #10 1.134 npm WARN config production Use --omit=dev instead. #10 2.757 npm ERR! code EUSAGE #10 2.763 npm ERR! #10 2.764 npm ERR! npm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with npm install before continuing. #10 2.764 npm ERR! #10 2.764 npm ERR! Invalid: lock file's [email protected] does not satisfy [email protected] #10 2.764 npm ERR! Missing: [email protected] from lock file #10 2.764 npm ERR! #10 2.764 npm ERR! Clean install a project #10 2.764 npm ERR! #10 2.764 npm ERR! Usage: #10 2.764 npm ERR! npm ci #10 2.764 npm ERR! #10 2.764 npm ERR! Options: #10 2.764 npm ERR! [--install-strategy <hoisted|nested|shallow|linked>] [--legacy-bundling] #10 2.765 npm ERR! [--global-style] [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]] #10 2.765 npm ERR! [--strict-peer-deps] [--foreground-scripts] [--ignore-scripts] [--no-audit] #10 2.765 npm ERR! [--no-bin-links] [--no-fund] [--dry-run] #10 2.765 npm ERR! [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]] #10 2.765 npm ERR! [-ws|--workspaces] [--include-workspace-root] [--install-links] #10 2.765 npm ERR! #10 2.765 npm ERR! aliases: clean-install, ic, install-clean, isntall-clean #10 2.765 npm ERR! #10 2.765 npm ERR! Run "npm help ci" for more info #10 2.768 #10 2.768 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-01-17T14_46_04_954Z-debug-0.log #10 ERROR: process "/bin/bash -ol pipefail -c npm ci" did not complete successfully: exit code: 1 -----
[stage-0 6/10] RUN --mount=type=cache,id=s/d5d61d44-679b-4ea8-ac52-6bddc8738b73-/root/npm,target=/root/.npm npm ci:
2.765 npm ERR! [--strict-peer-deps] [--foreground-scripts] [--ignore-scripts] [--no-audit] 2.765 npm ERR! [--no-bin-links] [--no-fund] [--dry-run] 2.765 npm ERR! [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]] 2.765 npm ERR! [-ws|--workspaces] [--include-workspace-root] [--install-links] 2.765 npm ERR! 2.765 npm ERR! aliases: clean-install, ic, install-clean, isntall-clean 2.765 npm ERR! 2.765 npm ERR! Run "npm help ci" for more info 2.768 2.768 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-01-17T14_46_04_954Z-debug-0.log ----- Dockerfile:20 ------------------- 18 | ENV NIXPACKS_PATH /app/node_modules/.bin:$NIXPACKS_PATH 19 | COPY . /app/. 20 | >>> RUN --mount=type=cache,id=s/d5d61d44-679b-4ea8-ac52-6bddc8738b73-/root/npm,target=/root/.npm npm ci 21 | 22 | # build phase ------------------- ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm ci" did not complete successfully: exit code: 1 Error: Docker build failed
maddsua
maddsua10mo ago
hmmmm, so it seems to be a problem with package lock anyway wait what package manager is used in the project? npm/pnpm/yarn?
Fragly
Fragly10mo ago
could you try running npm install --package-lock-only to sync your package lock file
Vinojan Abhimanyu
Npm It's getting same error
Fragly
Fragly10mo ago
weird, could you try deleting the package-lock.json entirely and then run npm install make sure you're comitting the changes afterwards
Vinojan Abhimanyu
Yes. I did it already..
Fragly
Fragly10mo ago
that is uncanny
Vinojan Abhimanyu
How can I solve it? Can't we deploy the Next application on Railway?
maddsua
maddsua10mo ago
that's something new, it would need more brainstorming we can it should just work out of the box that's the weird part about it
Vinojan Abhimanyu
What can I do now
maddsua
maddsua10mo ago
this line doesn't make any sense if you already removed lockfile and installed it as clean
No description
Fragly
Fragly10mo ago
it's saying your package-lock.json file and package.json is not synchronized deleting your package-lock.json and then running npm install should generate an entirely new package-lock.json which should be synchronized with your package.json file
maddsua
maddsua10mo ago
I have an idea tho wait try to remove both node_modules and package-lock at the same time and run npm install after that is done
Vinojan Abhimanyu
Okay wait.. But node_modules are not pushed to git neh? Is it useful?
Fragly
Fragly10mo ago
I think mad wants to make sure the npm install commands is working fully by deleting the existing node_modules folder although npm install will generate the package-lock.json file if it isn't there, whether node_modules exists or not could you send the new build logs you are getting? using this link: https://bookmarklets.up.railway.app/log-downloader/
Vinojan Abhimanyu
The same log and error getting
Fragly
Fragly10mo ago
Mind doing it anyway? I want to make absolutely sure Also, I'm assuming you're on Trial Plan, right?
Vinojan Abhimanyu
Yes.. I'm on trial plan
Brody
Brody10mo ago
have you tried a deployment without a package lock file?
Vinojan Abhimanyu
No I didn't try Wait a minute. I'll try
Fragly
Fragly10mo ago
I thought Railway depended on the lock file
Brody
Brody10mo ago
nope but of course ideally you do want to have one. if a package lock file is found npm ci is ran. if no package lock file is found npm i is ran.
Fragly
Fragly10mo ago
Ooh okay, thanks brody!
maddsua
maddsua10mo ago
yeah you can just deploy it without lockfile at all, but it can have it's own gotchas
Brody
Brody10mo ago
I know, this is just a test
maddsua
maddsua10mo ago
so generally you want to have it present totally get it
Vinojan Abhimanyu
🎉🎉🎉 It's done
Brody
Brody10mo ago
vinojan, what version of node are you using locally?
Vinojan Abhimanyu
18.18.2 One doubt guys... The application is deployed on Railway... Now how can I get the url from the dashboard.. Should I want to connect custom domain..?
maddsua
maddsua10mo ago
You probably wanna register a proper domain if the project is to be served to the public. On the other hand, for testing purposes railway.up domains are just fine It's mostly about SEO and brand recognition
Vinojan Abhimanyu
I generated the domain on Railway, when I redirect to the url, it's showing the Not Found error..
Brody
Brody10mo ago
takes a bit for railway to refresh their routing, give it a minute
maddsua
maddsua10mo ago
it had more than a few minutes, should already be up guessing for the second time today - wrong port?
Brody
Brody10mo ago
no? it's a 404, railway just haven't refreshed their routing just yet
maddsua
maddsua10mo ago
ok I shut up 🙂
Vinojan Abhimanyu
Thank you Fragly, Madhdsua, Brody Now the url is working. I think its took time to generate the route
Want results from more Discord servers?
Add your server