R
Railway•12mo ago
Fityan

`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:
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.
Jump to solution
21 Replies
Percy
Percy•12mo ago
Project ID: 3380be57-899c-4fa1-8a57-1724b9780dd7
Fityan
FityanOP•12mo ago
3380be57-899c-4fa1-8a57-1724b9780dd7
Brody
Brody•12mo ago
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 command
Fityan
FityanOP•12mo ago
I 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.
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "DOCKERFILE",
"watchPatterns": [
"!/*.md"
],
"dockerfilePath": "Dockerfile"
},
"deploy": {
"numReplicas": 1,
"startCommand": "npm run db:migrate;npm run start:prod",
"sleepApplication": false,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "DOCKERFILE",
"watchPatterns": [
"!/*.md"
],
"dockerfilePath": "Dockerfile"
},
"deploy": {
"numReplicas": 1,
"startCommand": "npm run db:migrate;npm run start:prod",
"sleepApplication": false,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
Brody
Brody•12mo ago
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 signs
Fityan
FityanOP•12mo ago
Yes, I have tried it
Brody
Brody•12mo ago
if your start command was just npm run start:prod does your app start and run just fine?
Fityan
FityanOP•12mo ago
Yeah, It works well.
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "DOCKERFILE",
"watchPatterns": [
"!/*.md"
],
"dockerfilePath": "Dockerfile"
},
"deploy": {
"numReplicas": 1,
"startCommand": "npm run start:prod",
"sleepApplication": false,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "DOCKERFILE",
"watchPatterns": [
"!/*.md"
],
"dockerfilePath": "Dockerfile"
},
"deploy": {
"numReplicas": 1,
"startCommand": "npm run start:prod",
"sleepApplication": false,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
Brody
Brody•12mo ago
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 me
Fityan
FityanOP•12mo ago
Here it is https://github.com/fityannugroho/idn-area/blob/prod/railway/prisma/migrate.ts Oh I thought you were the admin 😅
Brody
Brody•12mo ago
im not an admin, though i am a mod of this server would you mind trying to avoid ping replying me for every message?
Fityan
FityanOP•12mo ago
Sure
Brody
Brody•12mo ago
nothing bad stands out from your migrate.ts script, have you tried this service variable (first time i sent it there was a typo)
Fityan
FityanOP•12mo ago
NPM_CONFIG_UPDATE_NOTIFIER right? Let me try
Brody
Brody•12mo ago
yep
Fityan
FityanOP•12mo ago
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.
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "DOCKERFILE",
"watchPatterns": [
"!/*.md"
],
"dockerfilePath": "Dockerfile"
},
"deploy": {
"numReplicas": 1,
"startCommand": "npm run db:migrate;npm run start:prod",
"sleepApplication": false,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "DOCKERFILE",
"watchPatterns": [
"!/*.md"
],
"dockerfilePath": "Dockerfile"
},
"deploy": {
"numReplicas": 1,
"startCommand": "npm run db:migrate;npm run start:prod",
"sleepApplication": false,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
Brody
Brody•12mo ago
then it seems like something you are doing in the migration is exiting and not letting the second command run
Fityan
FityanOP•12mo ago
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:
"scripts": {
"db:migrate": "tsx prisma/migrate.ts",
"prestart": "npm run db:migrate",
"start": "node dist/src/main",
}
"scripts": {
"db:migrate": "tsx prisma/migrate.ts",
"prestart": "npm run db:migrate",
"start": "node dist/src/main",
}
Will the prestart be executed automatically before start?
Brody
Brody•12mo ago
that's more so a question for the npm documentation
Solution
Fityan
Fityan•12mo ago
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.
Brody
Brody•12mo ago
while this is some super strange behaviour, I can assure you this is not an issue with Railway
Want results from more Discord servers?
Add your server