One of my apps in Heroku have a memory leak in it, therefore I'm looking for a way to take heap snapshot
there.
I found several node-remote-debugging
packages, but node-inspector looks the most promising, but it needs to be installed globally.
Unfortunately, I couldn't find any info about how to install a global dependency on Heroku.
Install Package Globally js application on that computer can import and use the installed packages. NPM installs global packages into /<User>/local/lib/node_modules folder. Apply -g in the install command to install package globally.
Install the dependencies to the local node_modules folder. In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package. By default, npm install will install all modules listed as dependencies in package.
Run the npm install command in your local app directory to install the dependencies that you declared in your package. json file. Start your app locally using the heroku local command, which is installed as part of the Heroku CLI. Your app should now be running on http://localhost:5000/.
Path of Global Packages in the system: Global modules are installed in the standard system in root location in system directory /usr/local/lib/node_modules project directory. Command to print the location on your system where all the global modules are installed.
Why do you think it needs to be installed globally?
I'd recommend following these guidelines:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys#ensure-you-aren-t-relying-on-untracked-dependencies
npm install --save --save-exact node-inspector
At that point, it's accessible from npm scripts directly, or from node_modules/.bin/whatever outside of npm.
Keep in mind that you're limited to a single open port on Heroku (currently) so you probably won't be able to use node-inspector without some hacking (like reverse tunnel buildpacks). It may be easier to use the heapdump module to get heap snapshots:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With