aksakalli / gtop

System monitoring dashboard for terminal
MIT License
9.74k stars 326 forks source link

Cannot Install via NPM #126

Open InklingGirl opened 2 years ago

InklingGirl commented 2 years ago

It fails to install.

teknetik commented 2 years ago

+1

`Distributor ID: Ubuntu Description: Ubuntu 20.04.4 LTS Release: 20.04 Codename: focal

nodejs --version v10.19.0

Error:

/usr/local/lib/node_modules/gtop/node_modules/marked-terminal/index.cjs:333 && Number(osRelease[2]) >= 10_586 ^^

SyntaxError: Invalid or unexpected token at Module._compile (internal/modules/cjs/loader.js:723:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (/usr/local/lib/node_modules/gtop/node_modules/blessed-contrib/lib/widget/markdown.js:5:24) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

`

InklingGirl commented 2 years ago

@teknetik I've been able to find a solution on my own, I guess.

Add the official Node.js repo: curl -sL https://deb.nodesource.com/setup_17.x | sudo -E bash -

Followed by installing the nodejs meta-package (not npm) : sudo apt install nodejs

Followed by installing gtop w/ superuser permissions specifically: sudo npm install gtop -g

After that, gtop seems to work. If a developer/maintainer has any better advice or insight to contribute, we're still waiting to hear it; get around to your users' tickets!

InklingGirl commented 2 years ago

Add the official Node.js repo: curl -sL https://deb.nodesource.com/setup_17.x | sudo -E bash -

On Ubuntu 22.04, now: curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -

InklingGirl commented 2 years ago

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -

Alternatively, you could more manually set up the repo w/o curling that shell script, like this:

wget -O- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | sudo tee /usr/share/keyrings/nodesource.gpg

echo 'deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x jammy main
deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x jammy main' | sudo tee /etc/apt/sources.list.d/nodesource.list

Also, I recently found out you can install gtop & other Node.js packages w/ yarn, which is a faster package manager for them:

wget -O- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | sudo tee /usr/share/keyrings/nodesource.gpg

echo 'deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x jammy main
deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x jammy main' | sudo tee /etc/apt/sources.list.d/nodesource.list

wget -O- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg

echo 'deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main' | sudo tee /etc/apt/sources.list.d/yarn.list

sudo apt update

sudo apt install yarn

sudo yarn global add gtop

^ This is how I do it now. As shown, in addition to the Yarn repo you still need to add the Node.js repo, that's to get the latest nodejs package (for gtop to work at all), which will–unless you've messed w/ apt's defaults–be installed automatically alongside yarn as a recommended package.

Again, the maintainer should really update his project's README.md.