Trying to Install Rocket-CLI for App Dev

Description

I installed Node.js and npm, then tried to run the command, “sudo npm install -g @rocket.chat/apps-cli” per the instructions here: The Apps Engine CLI - Rocket.Chat Developer

The command failed and didn’t install the app engine cli.

Server Setup Information

  • Version of Rocket.Chat Server: Rocket 4.62
  • Operating System: OS Ubuntu 18.04
  • Deployment Method: Snap
  • Number of Running Instances: 1
  • DB Replicaset Oplog:
  • NodeJS Version: v10.19.0
  • MongoDB Version: ? - not sure
  • Proxy: Caddy proxy
  • Firewalls involved:

Any additional Information

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! esbuild@0.12.29 postinstall: node install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the esbuild@0.12.29 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/2022-05-06T19_15_17_627Z-debug.log

The log file didn’t contain any additional information.

image

I uninstalled node and npm, and tried to install them following a combination of techniques from this article: https://linuxize.com/post/how-to-install-node-js-on-ubuntu-18.04/

It seemed to do some things differently, and I got different errors when I tried to run the “sudo npm install -g @rocket.chat/apps-cli” command again, but it still failed. I don’t know if these different errors are helpful, but I am providing below.

$ sudo npm install -g @rocket.chat/apps-cli
npm WARN deprecated cli-ux@5.6.7: Package no longer supported. Contact Support at npm | Support for more info.
npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See There’s Math.random(), and then there’s Math.random() · V8 for details.
npm WARN deprecated cli-ux@5.6.6: Package no longer supported. Contact Support at npm | Support for more info.
npm WARN deprecated cryptiles@4.1.3: This module has moved and is now available at @hapi/cryptiles. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN deprecated boom@7.3.0: This module has moved and is now available at @hapi/boom. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
npm WARN deprecated hoek@6.1.3: This module has moved and is now available at @hapi/hoek. Please update your dependencies as this version is no longer maintained an may contain bugs and security issues.
/usr/bin/rc-apps → /usr/lib/node_modules/@rocket.chat/apps-cli/bin/run

esbuild@0.12.29 postinstall /usr/lib/node_modules/@rocket.chat/apps-cli/node_modules/esbuild
node install.js

Trying to install “esbuild-linux-64” using npm
Failed to install “esbuild-linux-64” using npm: EACCES: permission denied, mkdir ‘/usr/lib/node_modules/@rocket.chat/apps-cli/node_modules/esbuild/esbuild-ohkvzqdr1p’
Trying to download “https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.12.29.tgz
/usr/lib/node_modules/@rocket.chat/apps-cli/node_modules/esbuild/install.js:198
throw e;
^

Error: EACCES: permission denied, open ‘/usr/lib/node_modules/@rocket.chat/apps-cli/node_modules/esbuild/bin/esbuild__’
at Object.openSync (fs.js:462:3)
at Object.writeFileSync (fs.js:1384:35)
at installBinaryFromPackage (/usr/lib/node_modules/@rocket.chat/apps-cli/node_modules/esbuild/install.js:61:6)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
errno: -13,
syscall: ‘open’,
code: ‘EACCES’,
path: ‘/usr/lib/node_modules/@rocket.chat/apps-cli/node_modules/esbuild/bin/esbuild__’
}
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/@rocket.chat/apps-cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! esbuild@0.12.29 postinstall: node install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the esbuild@0.12.29 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/2022-05-06T20_47_52_052Z-debug.log

I had a similiar issue and found this: Issues · evanw/esbuild · GitHub

I found this Stack Overflow answer which says that if you’re using npm with the root user and a package has an install script, you’ll need to add --unsafe-perm=true to your npm command to get it to work. Does that work for you?

This solved the issue for me

That worked perfectly! You’re amazing, thank you for sharing!!
Natalie