1

I'm trying to use PeerJS in the command line after I've installed it using

npm i -g peerjs

and I can confirm it's installed globally as it shows when I run

npm list -g --depth 0

When I try to run peerjs in the command line, it throws a CommandNotFoundException.

I've tried adding these to my user PATH variable:

PATH

I've also tried uninstalling and reinstalling PeerJS, as well as running the NodeJS Command Line app which is meant to set up the environment.

Any help on getting this command working would be greatly appreciated.

Thanks.

Ryan S
  • 119
  • 2
  • 3
  • 9

2 Answers2

2

You probably meant to install the peer package, which is the PeerJS server. That is the one that provides the peerjs command. The peerjs package contains the API library.

cbr
  • 12,563
  • 3
  • 38
  • 63
  • Tried installing peer and restarting cmd and still not working. When I run npm list -g --depth 0, it now shows both peerjs and peer: +-- peer@0.6.1 `-- peerjs@1.3.1 – Ryan S Jan 12 '21 at 11:18
  • @RyanS If you go to `C:\Program Files\nodejs`, do you see `peerjs`? – cbr Jan 12 '21 at 11:21
  • You can also just use `npx peer`. – cbr Jan 12 '21 at 11:21
  • I don't, no. This is what I see: https://prnt.sc/wlqji0 Will try npx now. – Ryan S Jan 12 '21 at 11:22
  • @RyanS Which path does `npm prefix -g` output? – cbr Jan 12 '21 at 11:25
  • It outputs "C:\Users\Ryan" – Ryan S Jan 12 '21 at 11:35
  • Then your global packages are installed to `C:\Users\Ryan` and that's the path you need to add to your PATH. If you have a space in your username, you might need to change your npm prefix location to `C:\Users\Ryan~1`, or just change it to AppData\Roaming which I think is the default for the latest node versions. More about changing the path [here](https://stackoverflow.com/a/26894197/996081). – cbr Jan 12 '21 at 11:39
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/227198/discussion-between-ryan-s-and-cbr). – Ryan S Jan 12 '21 at 12:03
2

You probably need to install peerjs-server

npm install peer -g

then close the cmd and reopen and then use it in commandline

peerjs --port 9000 --key peerjs --path /myapp
Swapnil Soni
  • 965
  • 1
  • 10
  • 26
  • Tried installing peer and restarting cmd and still not working. When I run npm list -g --depth 0, it now shows both peerjs and peer: +-- peer@0.6.1 `-- peerjs@1.3.1 – Ryan S Jan 12 '21 at 11:18