run npm script

I have a rails c-style npm script that lets me interactively access my app’s context thru cli

I start it locally like so:

cd /path/to/my/app
npm run console

and on heroku like so:

heroku run npm run console -a <app-name>

Is there a way I can achieve that with fly?

The closest equivalent is flyctl ssh console · Fly Docs

To make things easier, create a script containing the lines you want to run, make it executable and put it in your application directory, and after you deploy you can run:

fly ssh console -C /app/console

Replace /app/console with the name of your script.

1 Like

For those in a similar situation, here’s the detail:

  1. create a file in the repo’s root with this content:
cd app && yarn console
  1. run:
chmod +x
  1. deploy app
  2. run:
fly ssh console -C /app/