Can you set aliases for npm scripts inside package.json?
I think the best solution is to work with NODE_ENV but first, you need to install:
npm install if-env --save
and then in the script:
"scripts": {"start": "if-env NODE_ENV=production ?? npm run start:prod || npm run start:dev","start:dev": "ts-node src/index","start:prod": "node src/index"
}
And on the server you need to set NODE_ENV to production
On Linux:
export NODE_ENV=production
And for production, I suggest using something like pm2 or foverer insted node to start an application