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

amazon-elastic-beanstalk, node.js, npm

Solution

Once logged in:

Choose your node version:

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

Run your command:

`cd /var/app/current/ npm ls`

Problem

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?

Original source

Related problems