Cannot install colyseus.js client via npm

I'm trying to install colyseus.js client via npm: npm install --save colyseus.js, but it returns an error:

root@04196b313c5a:/usr/src/app/frontend# npm install --save colyseus.js

> colyseus.js@0.10.8 postinstall /usr/src/app/frontend/node_modules/colyseus.js
> npm run -s donate

glob error { [Error: EACCES: permission denied, scandir '/root/.npm/_logs']
  stack:
   'Error: EACCES: permission denied, scandir \'/root/.npm/_logs\'',
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/root/.npm/_logs' }

npm ERR! code ELIFECYCLE
npm ERR! errno 243
npm ERR! colyseus.js@0.10.8 postinstall: `npm run -s donate`
npm ERR! Exit status 243
npm ERR! 
npm ERR! Failed at the colyseus.js@0.10.8 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-08-19T14_07_34_459Z-debug.log

The module gets never installed and I cannot import it.

Am I doing anything wrong?

Hi @rafaelbeckel, welcome!

That's the first time I see this, I've found this by googling the error:

sudo npm install --save colyseus.js --unsafe-perm=true --allow-root

Not sure why this happened to you though. Cheers!

@endel that command worked for me, thanks!

It happens when I run the command inside a node@10 docker container as root. In my machine, it works as expected without the extra -- options.

hi @rafaelbeckel , @endel , you may like to take note: sometimes if you running docker or vagrant, npm won't be able to install apps even as root if you are trying to do it inside a shared folder, you better login into the VM (using docker exec bash container or vagrant ssh), get into a folder inside the container but outside the shared folder (everything will run perfectly without any permission issues if you have node and npm properly installed), and then just move the node_modules inside your shared folder.
You could even create a small bash script to do something like:
$ cd ../ && mkdir temp-folder && cp ./your-shared-folder/package.json ./temp-folder && cd temp-folder && npm install && cd ../ && cp ./temp-folder/node_modules ./your-shared-folder && rm -R ./temp-folder
Looks awful as hell but it works :D