Ubuntu 18.04.2: Failed to install balena-cli successfully

Hi,

I tried unsuccessfully to install balena-cli on my Ubuntu 18.04.2. I tried it:

  1. With and without sudo.
  2. Uninstall and reinstall npm,
  3. Removed ~/.node-gyp folder and then the ~/.npmrc and rebooted
  4. Installed node@10

I’m out of alternatives, can someone help me out?

npm install balena-cli -g --production --unsafe-perm

npm WARN deprecated graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
/home/sylvain/.node_modules/bin/balena -> /home/sylvain/.node_modules/lib/node_modules/balena-cli/bin/balena

> ext2fs@1.0.26 install /home/sylvain/.node_modules/lib/node_modules/balena-cli/node_modules/ext2fs
> prebuild-install || node-gyp rebuild

sh: 1: prebuild-install: not found
internal/modules/cjs/loader.js:611
    throw err;
    ^

Error: Cannot find module 'graceful-fs'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:609:15)
    at Function.Module._load (internal/modules/cjs/loader.js:535:25)
    at Module.require (internal/modules/cjs/loader.js:663:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/usr/share/node-gyp/lib/node-gyp.js:12:10)
    at Module._compile (internal/modules/cjs/loader.js:734:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
    at Module.load (internal/modules/cjs/loader.js:626:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
    at Function.Module._load (internal/modules/cjs/loader.js:558:3)
/home/sylvain/.node_modules/lib
└── (empty)

npm WARN optional Skipping failed optional dependency /balena-cli/removedrive:
npm WARN notsup Not compatible with your operating system or architecture: removedrive@1.1.2
npm WARN optional Skipping failed optional dependency /balena-cli/denymount/macmount:
npm WARN notsup Not compatible with your operating system or architecture: macmount@1.0.0
npm WARN optional Skipping failed optional dependency /balena-cli/etcher-sdk/winusb-driver-generator:
npm WARN notsup Not compatible with your operating system or architecture: winusb-driver-generator@1.2.4
npm WARN balena-request@10.0.1 requires a peer of balena-auth@^2.0.0 but none was installed.
npm WARN resin-register-device@5.0.0 requires a peer of resin-request@^9.0.2 but none was installed.
npm ERR! Linux 4.15.0-45-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "balena-cli" "-g" "--production" "--unsafe-perm"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE

npm ERR! ext2fs@1.0.26 install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ext2fs@1.0.26 install script 'prebuild-install || node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ext2fs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     prebuild-install || node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs ext2fs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls ext2fs
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/sylvain/Documents/source/mobius/npm-debug.log
npm ERR! code 1

sudo npm install balena-cli -g --production --unsafe-perm

npm WARN deprecated graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
/usr/local/bin/balena -> /usr/local/lib/node_modules/balena-cli/bin/balena

> ext2fs@1.0.26 install /usr/local/lib/node_modules/balena-cli/node_modules/ext2fs
> prebuild-install || node-gyp rebuild


> mountutils@1.3.16 install /usr/local/lib/node_modules/balena-cli/node_modules/mountutils
> prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=11.9.0 runtime=node arch=x64 platform=linux)
internal/modules/cjs/loader.js:611
    throw err;
    ^

Error: Cannot find module 'graceful-fs'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:609:15)
    at Function.Module._load (internal/modules/cjs/loader.js:535:25)
    at Module.require (internal/modules/cjs/loader.js:663:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/usr/share/node-gyp/lib/node-gyp.js:12:10)
    at Module._compile (internal/modules/cjs/loader.js:734:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
    at Module.load (internal/modules/cjs/loader.js:626:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
    at Function.Module._load (internal/modules/cjs/loader.js:558:3)
/usr/local/lib
└── (empty)

npm WARN optional Skipping failed optional dependency /balena-cli/removedrive:
npm WARN notsup Not compatible with your operating system or architecture: removedrive@1.1.2
npm WARN optional Skipping failed optional dependency /balena-cli/denymount/macmount:
npm WARN notsup Not compatible with your operating system or architecture: macmount@1.0.0
npm WARN optional Skipping failed optional dependency /balena-cli/etcher-sdk/winusb-driver-generator:
npm WARN notsup Not compatible with your operating system or architecture: winusb-driver-generator@1.2.4
npm WARN resin-register-device@5.0.0 requires a peer of resin-request@^9.0.2 but none was installed.
npm WARN balena-request@10.0.1 requires a peer of balena-auth@^2.0.0 but none was installed.
npm ERR! Linux 4.15.0-45-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "balena-cli" "-g" "--production" "--unsafe-perm"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE

npm ERR! mountutils@1.3.16 install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the mountutils@1.3.16 install script 'prebuild-install || node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the mountutils package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     prebuild-install || node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs mountutils
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls mountutils
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/sylvain/Documents/source/mobius/npm-debug.log
npm ERR! code 1

@SylvainAON3D, thank you for reporting this. I will be trying to reproduce the npm install issue on Ubuntu 18.04. Meanwhile, I wanted to suggest that you tried the “standalone install” described on the following page, as it avoids the need for npm:
https://www.balena.io/docs/reference/cli/#standalone-install

Thanks @pdcastro, I can now use balena-cli. Keep me posted as it will ease future update to install it correctly.

@SylvainAON3D, I have had success installing the CLI on an Ubuntu 18.04 docker container by using nvm, which gives us more control over the installation of node:

To run an Ubuntu 18.04 container on my laptop:

$ docker pull amd64/ubuntu:18.04
$ docker run -it amd64/ubuntu:18.04 /bin/bash

Then on the Ubuntu container shell:

$ apt-get update && apt-get install git make g++ python curl
# Install nvm
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
$ bash -i  # so that the nvm installation takes effect
$ nvm install 8.14.1 --latest-npm
$ nvm use 8.14.1
$ node --version
v8.14.1
$ npm --version
6.4.1
$ npm install balena-cli -g --production --unsafe-perm
$ balena version
9.12.2

Now, when you wrote “keep me posted as it will ease future update to install it correctly”, I would not say that installing or updating the CLI through npm is any more correct than using the standalone install… If the standalone install is easier to get working, then that’s the correct one! :slight_smile:

I have done the same steps as you did and I did successfully update the balena-cli, I prefer that way so I can update it easily to a newer package if needed.

Thanks.

I gets installed well on Ubuntu 18.04 docker image
But then why it fails on Ubuntu 18.04 host

Hi @viveksaxena! Can you provide some logs on both cases, and the dockerfile of the Ubuntu 18.04 image you are using for taking a look into this?

@viveksaxena, I don’t currently know the exact reason why the “npm install” command fails on a fresh installation of Ubuntu 18.04, other than knowing it is because of some incompatibility between the node-gyp native module compilation framework and the Node installation that ships with Ubuntu by default. I have observed that installing Node via nvm (don’t confuse npm with nvm!) “solves” that incompatibility. Where possible, to avoid any compilation issues, I recommend using the “standalone zip packages” instead of “npm install” (see install instructions).

Additional improvements to the installations methods for Linux are on the CLI’s roadmap: we intend to provide a “deb package”, so that eventually (not yet) it will be possible to run something like “apt-get install balena-cli”.