Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run an arbitrary npm script on an Elastic Beanstalk instance

Tags:

I'm trying to debug an issue with a Node application running on Elastic Beanstalk. The issue appears only under EB, and I can't reproduce on a dev machine, even when running with production configuration locally.

Unlike other EB platforms, the Node platform really seems to go out of its way to hide the Node bin/ path so you can't run npm or node commands from a shell. I realize that you don't normally want to operate this way under EB, but I also need a shorter debugging feedback loop than waiting 5 minutes for an EB deploy to test every little tweak.

Piecing together information from here and here I understand where the pieces are, but what is the most straightforward way to run a simple npm run script command?

like image 336
gtd Avatar asked Oct 28 '16 22:10

gtd


People also ask

Does Elastic Beanstalk run npm install?

When a package. json file is present, Elastic Beanstalk runs npm install to install dependencies. It also uses the start command to start your application.

How do I run a custom npm script?

To define an NPM script, set its name and write the script under the 'scripts' property of your package. json file: To execute your Script, use the 'npm run <NAME-OF-YOUR-SCRIPT>' command. Some predefined aliases convert to npm run, like npm test or npm start, you can use them interchangeably.

What is Procfile Elastic Beanstalk?

Example Procfile Elastic Beanstalk assumes that all entries in the Procfile should run at all times and automatically restarts any application defined in the Procfile that terminates. To run commands that will terminate and should not be restarted, use a Buildfile.


1 Answers

Once logged in:

  1. Choose your node version:

    export PATH=$PATH:/opt/elasticbeanstalk/node-install/node-v8.11.1-linux-x64/bin/

  2. Run your command:

    cd /var/app/current/ npm ls

like image 71
Arthur Cinader Avatar answered Sep 26 '22 16:09

Arthur Cinader