Cant install PM2 globally due to "Missing Permissions"


#1

Hey there Glitch community, so im trying to install the PM2 npm module (https://www.npmjs.com/package/pm2) using the command npm install -g pm2 on the Glitch Terminal but I get this awkward permission error and the installation fails, how could I fix this or is this an issue on your guys end? Thanks.


#2

Hi @CheatTriggers,

The following steps will allow you to install global packages in your assigned Glitch instance:

  1. Create a directory for global packages
$ mkdir "${HOME}/.npm-packages"
  1. To let know npm to use the directory, add this in ~/.npmrc (you can use $ vi ~/.npmrc)
prefix=${HOME}/.npm-packages
  1. The create and modify the file under ~/.bashrc and add the following content
NPM_PACKAGES="${HOME}/.npm-packages"

PATH="$NPM_PACKAGES/bin:$PATH"

# Unset manpath so we can inherit from /etc/manpath via the `manpath` command
unset MANPATH # delete if you already modified MANPATH elsewhere in your config
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"

After that, load ~/.bashrc into the terminal

source ~/.bashrc

That’s it. Now you will be able to install global packages. I tested with pm2 and I was able to install and call the package after installation.


#3

Thanks it worked perfectly! :smiley:


#4

Hello,

actually the easiest way to install “global” packages is to put them in package.json. They will immediately be available in the terminal and in the project.


#5

This problem has crept back up again. I was able to solve it with the .npm-packages trick… but that’s not an awesome long-term solution.

Do you folks intend to restore the earlier functionality?


#6

Does adding them to your package.json file as suggested above not work for you?


#7

Nah. I tried both methods. It installed it locally, but not globally.


#8

And what’s the difference? Glitch adds the local binaries to your path, so it should work exactly the same


#9

That’s the issue. I’m getting a permission denied error.

See this screencast of the error:


#10

Sure, the suggestion though was to add it to your package.json file, which seems to work without issue - see https://glitch.com/edit/#!/scythe-impulse for example. If you remix it, you can run firebase from the console.


#11

I tried adding it via package.json earlier, but it added it locally, not globally.

I just tried to reproduce it as a screencast, but the button to open the console is gone now :frowning:

Is there something that I need to do to enable that console button under advanced options, or is it just down for maintenance?


#12

In Glitch, there is no difference between “locally” and “globally”. You can install it “locally” and you get it everywhere.

Can you please try what we are suggesting? You’ll see that it will work exactly as you want. If it doesn’t, describe exactly what is missing. Thanks :slight_smile:


#13

I will try it and send you a screencast. For some reason I can’t get to the console right now. the “OPEN CONSOLE” button is missing. I’ll keep trying to break into the console :slight_smile:


#14

Well now it works. Sorry for the false alarm. I tried all install options this morning, and none of them work. Now it’s working just fine!


#15

Awesome :slight_smile: The console is in Project Menu -> Advanced Options -> Open Console


#16

Actually it just moved - it’s under the logs panel now!