R

Railway

βœ‹ο½œhelp

Join Server

NestJS Build Error

FFederaco9/26/2022
Hi, I created a Railway project with a NestJS API and a Postgres DB, it was working fine, but after a while I wanted to create a second project so I can have a test environment, I followed the same setup steps of the working project, but I can't get it working.

The project was generated with the nest cli.
The start command for the API is "npm install && npm run start:prod"
I created an Empty Service in Railway

I'm getting this error:

 
#11 2.235 npm ERR! code EUSAGE
 
#11 2.239 npm ERR!
#11 2.239 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.
#11 2.239 npm ERR!
#11 2.239 npm ERR! Missing: bindings@1.5.0 from lock file
#11 2.239 npm ERR! Missing: nan@2.16.0 from lock file
#11 2.239 npm ERR! Missing: file-uri-to-path@1.0.0 from lock file
#11 2.239 npm ERR!
#11 2.239 npm ERR! Clean install a project
#11 2.239 npm ERR!
#11 2.239 npm ERR! Usage:
#11 2.239 npm ERR! npm ci
#11 2.239 npm ERR!
#11 2.239 npm ERR! Options:
#11 2.239 npm ERR! [--no-audit] [--foreground-scripts] [--ignore-scripts]
#11 2.239 npm ERR! [--script-shell <script-shell>]
#11 2.239 npm ERR!
#11 2.239 npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
#11 2.240 npm ERR!
#11 2.240 npm ERR! Run "npm help ci" for more info
#11 2.242
 
#11 2.242 npm ERR! A complete log of this run can be found in:
#11 2.242 npm ERR!     /root/.npm/_logs/2022-09-24T23_56_10_362Z-debug-0.log
#11 ERROR: executor failed running [/bin/bash -ol pipefail -c npm ci]: exit code: 1
-----
> [stage-0 7/9] RUN --mount=type=cache,id=s/ca773b95-199f-4c52-94bc-3d867b679908-/root/npm,target=/root/.npm npm ci:
-----
executor failed running [/bin/bash -ol pipefail -c npm ci]: exit code: 1
 
Error: Docker build failed


Thanks community!
UUUnknown User9/26/2022
Message Not Public
Sign In & Join Server To View
FFederaco9/26/2022
There it is. Thank you!
UUUnknown User9/27/2022
Message Not Public
Sign In & Join Server To View
FFederaco10/1/2022
Thanks for the response. I just tried it and I got the same error πŸ˜•
FFederaco10/1/2022
Hi neb!, sorry to bother you, I sent you my package.json, it looks you have an idea about solving this error, can you share it?, so I can try it?, thank you very much!
FFederaco10/1/2022
I just created a new NestJS project, and put it into a public repo, used that repo to build in Railway, and I'm still getting the (kind of) same error:

#8 [4/4] RUN  npm run build
#8 sha256:2217b003228b75aae7ee4c8dedf164373c980810992dfd322ee273fd092d4bff
 
#8 0.425 /bin/bash: line 1: npm: command not found
#8 ERROR: executor failed running [/bin/bash -ol pipefail -c npm run build]: exit code: 127
-----
> [4/4] RUN  npm run build:
-----
executor failed running [/bin/bash -ol pipefail -c npm run build]: exit code: 127
 
Error: Docker build failed


This is the repo: https://github.com/federicopenaranda/nestjs-railway

It looks like my project code is not the problem, because I just generated a new NestJS project and didn't add any new feature or library. Thanks for all the help.
UUUnknown User10/1/2022
Message Not Public
Sign In & Join Server To View
FFederaco10/1/2022
Sure:

==============
Using Nixpacks
==============
 
╔════════ Nixpacks v0.9.0 ════════╗
β•‘ build      β”‚ npm run build      β•‘
║─────────────────────────────────║
β•‘ start      β”‚ npm run start:prod β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
 
 
#1 [internal] load build definition from Dockerfile
#1 sha256:36493a9c8cd43ec4c0686cec3ddf684e2a64f5f343f26b4e98ab3ba66bbf636b
#1 transferring dockerfile: 1.18kB done
#1 DONE 0.1s
 
#2 [internal] load .dockerignore
#2 sha256:4563847ef7b248e624485e2c63a65bd8d867a82089908af4b13ae9fb5035316e
 
#2 transferring context: 2B done
#2 DONE 0.1s
 
 
#3 [internal] load metadata for ghcr.io/railwayapp/nixpacks:debian-1664237509
#3 sha256:14654d6ad0ab90f84b1d5bb7e36d9fe0da64cb0dce7f66299caee27917d0e4b3
 
#3 DONE 0.2s
 
 
#4 [stage-0  1/11] FROM ghcr.io/railwayapp/nixpacks:debian-1664237509@sha256:b9d126f523701b3c9e6629706f2129990b21f731e3091fe579207cd4805fa27d
#4 sha256:e6e39311ac6d3f89532fa59c41fc892def134eb3f4b0f5af71ce50ddd618cfcb
#4 DONE 0.0s
 
#5 [stage-0  2/11] WORKDIR /app/
#5 sha256:17c3ef9792c541c82fadcc87ddae9be2606103ef7a3fa9bdd701b9e786361f83
#5 CACHED
 
#6 [internal] load build context
#6 sha256:f23ed8d63423c145a2a3f9432fe1ecb2889f08564d83e44bcfbcb75faf2c80dc
#6 transferring context: 575.51kB done
#6 DONE 0.1s
 
 
#7 [3/4] COPY . /app/
#7 sha256:a97833c6270af3d00cceac5c4be9d87e79e04072418738ffc559595dc1cf5afb
 
#7 DONE 0.1s
 
#8 [4/4] RUN  npm run build
#8 sha256:2217b003228b75aae7ee4c8dedf164373c980810992dfd322ee273fd092d4bff
 
#8 0.425 /bin/bash: line 1: npm: command not found
#8 ERROR: executor failed running [/bin/bash -ol pipefail -c npm run build]: exit code: 127
-----
> [4/4] RUN  npm run build:
-----
executor failed running [/bin/bash -ol pipefail -c npm run build]: exit code: 127
 
Error: Docker build failed
UUUnknown User10/1/2022
Message Not Public
Sign In & Join Server To View
FFederaco10/1/2022
yes, build command:
npm run build
, start command:
npm run start:prod
UUUnknown User10/1/2022
Message Not Public
Sign In & Join Server To View
FFederaco10/1/2022
I should leave them blank?
UUUnknown User10/1/2022
Message Not Public
Sign In & Join Server To View
FFederaco10/1/2022
let me try..
FFederaco10/1/2022
neb, I tried and it built successfully!, but then I tried again with the commands I wrote manually, and it worked too!!!, I don't know why this is happening. Anyway, I tried in my original project (the one I got the error in the first place) and I'm getting the same error as before:

#12 [stage-0  8/10] RUN --mount=type=cache,id=s/ca773b95-199f-4c52-94bc-3d867b679908-/root/npm,target=/root/.npm npm ci
 
#12 sha256:78abb8d0f5f6bfc16201979e02eae7fbd4865a0452eefdd5f0664ad196c546de
 
#12 0.868 npm
WARN config production Use `--omit=dev` instead.
 
#12 2.108 npm ERR! code EUSAGE
#12 2.112 npm ERR!
#12 2.112 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.
#12 2.112 npm ERR!
#12 2.112 npm ERR! Missing: bindings@1.5.0 from lock file
#12 2.112 npm ERR! Missing: nan@2.16.0 from lock file
#12 2.112 npm ERR! Missing: file-uri-to-path@1.0.0 from lock file
#12 2.112 npm ERR!
#12 2.112 npm ERR! Clean install a project
#12 2.112 npm ERR!
#12 2.112 npm ERR! Usage:
#12 2.112 npm ERR! npm ci
#12 2.112 npm ERR!
#12 2.112 npm ERR! Options:
#12 2.112 npm ERR! [--no-audit] [--foreground-scripts] [--ignore-scripts]
#12 2.112 npm ERR! [--script-shell <script-shell>]
#12 2.112 npm ERR!
#12 2.112 npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
#12 2.112 npm ERR!
#12 2.113 npm ERR! Run "npm help ci" for more info
#12 2.114
#12 2.115 npm ERR! A complete log of this run can be found in:
#12 2.115 npm ERR!     /root/.npm/_logs/2022-10-01T13_53_37_860Z-debug-0.log
 
#12 ERROR: executor failed running [/bin/bash -ol pipefail -c npm ci]: exit code: 1
-----
> [stage-0  8/10] RUN --mount=type=cache,id=s/ca773b95-199f-4c52-94bc-3d867b679908-/root/npm,target=/root/.npm npm ci:
-----
 
executor failed running [/bin/bash -ol pipefail -c npm ci]: exit code: 1
 
Error: Docker build failed
UUUnknown User10/1/2022
Message Not Public
Sign In & Join Server To View
FFederaco10/1/2022
I tried with the blank build and start commands there πŸ‘†
UUUnknown User10/1/2022
Message Not Public
Sign In & Join Server To View
FFederaco10/1/2022
ok, trying....
FFederaco10/1/2022
npm i
install all packages, but node_modules folder is in .gitignore file, so there is nothing to commit πŸ€”
UUUnknown User10/1/2022
Message Not Public
Sign In & Join Server To View
FFederaco10/1/2022
nothing, same error, I'm trying with and without build/start commands
UUUnknown User10/1/2022
3 Messages Not Public
Sign In & Join Server To View
FFederaco10/1/2022
yes, I'm using a single repo for frontend and backend, that's why I have nested node apps (one is in Angular and the backend is in NestJS), but I thought that specifying the Root Directory in settings would fix that issue.
This is the project id?: overconfident-milk
FFederaco10/1/2022
Or this one?: 42798527-bf72-4257-95f1-b3e4cdc0ef0a/service/ca773b95-199f-4c52-94bc-3d867b679908
UUUnknown User10/1/2022
2 Messages Not Public
Sign In & Join Server To View
FFederaco10/1/2022
ohh, ok
UUUnknown User10/1/2022
4 Messages Not Public
Sign In & Join Server To View
FFederaco10/1/2022
ok, thanks
FFederaco10/1/2022
where should I put the "NIXPACKS_INSTALL_CMD=npm i" command?
FFederaco10/1/2022
nevermind, in the Variables tab!
FFederaco10/2/2022
the NIXPACKS_INSTALL_CMD variable fixed the issue!, thank you very much!