`npm notice` stop the deploy
My app successfully deployed before with custom start command
npm run start:prod
.
But I need to run database migration before app starting, so I tried to add additional command like this:
npm run db:migrate && npm run start:prod
.
Then, the deployment failed with this logs (see the image).
So I think this is bug that the app throw error because of the npm notice.Solution:Jump to solution
For now, I can get around this by adding
RUN npm run db:migrate
in the Dockerfile. But I hope Railway can provide a better way in the future.21 Replies
Project ID:
3380be57-899c-4fa1-8a57-1724b9780dd7
3380be57-899c-4fa1-8a57-1724b9780dd7
I can't see how the notice would effect anything, but just to be sure, you can disable that npm notice by setting a service variable
NPM_CONFIG_UPDATE_NOTIFIER
to false
.
(might as well add that service variable regardless, that update notification is kinda annoying)
just a theory but maybe the migration is exiting with a non zero exit code when there is no migrations to apply, we can check this theory by replacing &&
with a semicolon ;
this will run the second command regardless of the exit code from the first commandI have tried your suggestions. First, I think
NPM_CONFIG_UPDATE_NOTIFIE=false
doesn't work because the npm notice still exists (see the screenshot).
Second, I also change &&
with ;
and it seems not worked too.
so sorry, it was a copy error, the variable is
NPM_CONFIG_UPDATE_NOTIFIER
but did you try the start command with a semicolon instead of the double and signsYes, I have tried it
if your start command was just
npm run start:prod
does your app start and run just fine?Yeah, It works well.
what is the script for
db:migrate
?
side note, you dont need to send the deploy ids, i dont work for railway so they are useless to meHere it is
https://github.com/fityannugroho/idn-area/blob/prod/railway/prisma/migrate.ts
Oh I thought you were the admin 😅
im not an admin, though i am a mod of this server
would you mind trying to avoid ping replying me for every message?
Sure
nothing bad stands out from your migrate.ts script, have you tried this service variable (first time i sent it there was a typo)
NPM_CONFIG_UPDATE_NOTIFIER
right? Let me tryyep
NPM_CONFIG_UPDATE_NOTIFIER=false
works, no more npm notice, but it seems that npm run start:prod
command was never executed after the migration is completed.
then it seems like something you are doing in the migration is exiting and not letting the second command run
It is works well when I run it with docker compose in my local.
https://github.com/fityannugroho/idn-area/blob/prod/railway/docker-compose.yml
Let's say I don't change the railway custom start command, instead I change the script command in package.json like this:
Will the
prestart
be executed automatically before start
?that's more so a question for the npm documentation
Solution
For now, I can get around this by adding
RUN npm run db:migrate
in the Dockerfile. But I hope Railway can provide a better way in the future.while this is some super strange behaviour, I can assure you this is not an issue with Railway