Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to install global package in heroku

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.

like image 746
kutomer Avatar asked Oct 08 '15 14:10

kutomer


People also ask

How do I install a global package?

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.

How do you install a global package with npm?

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.

How install npm on Heroku?

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/.

Where is global npm package installed?

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.


1 Answers

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:

  • https://github.com/bnoordhuis/node-heapdump
like image 76
hunterloftis Avatar answered Sep 30 '22 00:09

hunterloftis