NestJS Build Error
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:
Thanks community!
26 Replies
send
package.json
There it is. Thank you!
Try the following on Railway UI:
Build Command:
npm run build
Start Command: npm run start:prod
Thanks for the response. I just tried it and I got the same error š
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!
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:
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.
GitHub
GitHub - federicopenaranda/nestjs-railway: Test nestjs build in rai...
Test nestjs build in railway. Contribute to federicopenaranda/nestjs-railway development by creating an account on GitHub.
can you send the entire logfile
Sure:
okay have you set a start and build command manually?
yes, build command: , start command:
you should remove those from railway
I should leave them blank?
yes
let me try..
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:
yeah thats a different error
I tried with the blank build and start commands there š
to fix it run
npm i
locally and commit itok, trying....
install all packages, but node_modules folder is in .gitignore file, so there is nothing to commit š¤
remove
package-lock.json
from gitignorenothing, same error, I'm trying with and without build/start commands
The problem here is that we did not detect that it is a Node app since the
package.json
file is nested within the railway/
directory
The problem here is that the lockfile is out of date with the package.json file which should be resolved locally before building for production. You can run npm i
and then commit the changes in the lockfile
Do you have a project id?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
Or this one?: 42798527-bf72-4257-95f1-b3e4cdc0ef0a/service/ca773b95-199f-4c52-94bc-3d867b679908
This one, yeah
The ca77*** thing
ohh, ok
Well actually you can easily get from project settings and under general tab (as we have already got the Id, wont continue this topic)
I thought that specifying the Root Directory in settings would fix that issue.It did fix the Node not detected issue. The new issue is that the lockfile is out of date. If you don't care about that you can set the
NIXPACKS_INSTALL_CMD=npm i
and it will install without checking the lockfile
Also it is using the lockfile in the root directory
not at the repo rootok, thanks
where should I put the "NIXPACKS_INSTALL_CMD=npm i" command?
nevermind, in the Variables tab!
the NIXPACKS_INSTALL_CMD variable fixed the issue!, thank you very much!