@osde8info, thank you for sharing the errors and feedback. I have just updated the “official” installation instructions to emphasise the recommendation of selecting the standalone zip package for Linux when using the Windows Subsystem for Linux. The main advantage of the standalone zip package is that it avoids the need for installing Node/npm/nvm and compiling source code, which is time consuming, somewhat error prone, and requires several dependencies to be pre-installed.
I gather that all the errors you shared were related to the NPM installation, which we only recommend to Node.js developers who are specifically interested in installing the CLI with
npm, such as source code contributors to the CLI.
You can find out more about the different installation options at: https://github.com/balena-io/balena-cli/blob/master/INSTALL.md
I’ve just successfully tested both the standalone zip package (Linux) and the NPM installation on the Windows Subsystem for Linux (WSL 1, not WSL 2).
What follows regards the NPM installation and the errors you shared, but I don’t really recommend pursuing it unless you have a specific reason to. On WSL, I recommend using the standalone zip package for Linux instead.
Looking at the error messages you shared for the NPM installation option, a few of them mention “Permission denied”. What comes to mind is that some installation steps (including the
nvm installation) may have been performed by the root user, and others by a non-root user (
cdarra). I have also noticed a mix of “nvm Node” and “system Node”:
npm WARN tar ENOENT: no such file or directory, open '/root/.nvm/versions/node/v13.11.0/lib/node_modules/...'
“System Node:” (i.e. a Node installation using something like
sudo apt-get install node)
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "balena-cli" "-g" "--production" "--unsafe-perm"
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
With WSL / Ubuntu, avoid using the “system Node” if possible, as pointed out in the instructions for the NPM installation option.
In my NPM installation test on WSL, I chose to use
nvm and installed it as a non-root user. Note how the command
which node below points to
"/home/paulo/.nvm/..." instead of
"/root/.nvm/..." as in some of the logs you shared:
paulo@DESKTOP-3021L0B:~$ nvm use 13.11.0
Now using node v13.11.0 (npm v6.13.7)
paulo@DESKTOP-3021L0B:~$ which node
paulo@DESKTOP-3021L0B:~$ node --version
paulo@DESKTOP-3021L0B:~$ npm install balena-cli -g --production
paulo@DESKTOP-3021L0B:~$ which balena
paulo@DESKTOP-3021L0B:~$ balena version -a
balena-cli version "11.29.5"
Node.js version "13.11.0"
Above I used Node version 13.11.0 to match your error report, but the balena CLI has been mostly tested with Node versions 8, 10 and 12 (not 13), as mentioned in the installation instructions.
Also, in my WSL installation, I did not install Node using
/usr/bin/node does not exist, which helps avoid confusion:
paulo@DESKTOP-3021L0B:~$ /usr/bin/node --version
No such file or directory
If you had a specific reason to install
nvm for the
root user, then run the
npm install command as the root user as well. Otherwise, I recommend installing both
nvm and the CLI as a non-root user. You can remove the
nvm installation for the root user with the commands:
rm -rf /root/.nvm
Then, as a non-root user, without using
nvm and some version of Node (e.g.
nvm install 10.18.1, to give you a version number) as per instructions in nvm’s website.
The balena-cli NPM installation option also requires additional dependencies to be installed. The installation instructions mention the following line for the Windows Subsystem for Linux:
sudo apt-get install -y python git make g++
Then finally, as the same ordinary user used to install
nvm (without using
sudo), install balena-cli:
npm install balena-cli -g --production --unsafe-perm
The instructions for the NPM installation option include a note regarding the
--unsafe-perm option. In my test on WSL with
nvm as a non-root user, the
--unsafe-perm option was not required, and did not appear to make any difference.
Some final notes regarding WSL support:
- The most common CLI commands should work well on WSL, but there are some commands that require some Linux features not provided by WSL. You can use/install both the CLI for Windows (to use with PowerShell or in a cmd.exe prompt) and the standalone zip package for Linux (to use in a WSL prompt) at the same time, which together should give you a wider coverage of supported commands.
- Everything I mentioned in this post regards WSL 1. The balena CLI team is yet to test WSL 2, so I cannot yet comment on it.