How to free up space? node uses more than 8 GB space

I was wondering why my 40 GB VPS only has 12 GB space left, then I run sudo du -h / | sort -h and was surprised to see that more than 8 GB is used by only node in the directories

|4.7G|/usr/local/n|
|---|---|
|4.7G|/usr/local/n/versions|
|4.7G|/usr/local/n/versions/node|
|3.6G|/opt/node_n/n|
|---|---|
|3.6G|/opt/node_n/n/versions|
|3.6G|/opt/node_n/n/versions/node|

Can be something done about it? Is all this space necessary? There seem to be node versions from 10 to 15 installed in both the /opt/node_n and usr/local/n

Thanks!

1 Like

Indeed that sounds overkill … I’m wondering what in node/n exactly takes so much space … Are you able to dig in /usr/local/n/versions/node and /opt/node_n/n/versions/node to find out how much the subfolders weight ?

More or less it’s the same size, seem to be too many versions, old versions don’t get deleted?

Excerpt:

113M	/usr/local/n/versions/node/14.17.2
113M	/usr/local/n/versions/node/14.17.3
113M	/usr/local/n/versions/node/14.17.4
113M	/usr/local/n/versions/node/14.17.5
113M	/usr/local/n/versions/node/14.17.6
113M	/usr/local/n/versions/node/14.18.0
113M	/usr/local/n/versions/node/14.18.1
4.7G	/usr/local/n/versions/node

and here the other excerpt:

101M	/opt/node_n/n/versions/node/15.14.0
106M	/opt/node_n/n/versions/node/6.17.1
112M	/opt/node_n/n/versions/node/14.15.5
113M	/opt/node_n/n/versions/node/14.18.0
150M	/opt/node_n/n/versions/node/14.15.4
150M	/opt/node_n/n/versions/node/14.16.0
150M	/opt/node_n/n/versions/node/14.16.1
150M	/opt/node_n/n/versions/node/14.17.0
151M	/opt/node_n/n/versions/node/14.17.1
151M	/opt/node_n/n/versions/node/14.17.3
151M	/opt/node_n/n/versions/node/14.17.4
151M	/opt/node_n/n/versions/node/14.17.6
3.6G	/opt/node_n/n/versions/node

Yeah it’s a known issue that those doesn’t get cleanedup … but I’m surprised that it ends up weighting so much, and that there’s also stuff in /usr/local/n/versions/node which apparently is different from the content in /opt/node_n/n/versions/node (for example the size for 14.17.3 is different on both side) :confused:

Can you share the output of /opt/node_n/ynh_app_version ? (Possibly redact the app names if you want)

Here you go, there are some apps that I have deinstalled some time ago

etherpad_mypads:6
wekan:8.15.1
etherpad_mypads:6
wekan:8.16.1
wekan:8.16.2
etherpad_mypads:10
codimd:10
etherpad_mypads:12
etherpad_mypads:12
cryptpad:14
cryptpad:14
cryptpad:14
cryptpad:14
cryptpad:14
etherpad_mypads:12
cryptpad:14
etherpad_mypads:14
cryptpad:14
etherpad_mypads:14
cryptpad:14
mumble-web:12
cryptpad:14
etherpad_mypads:14
cryptpad:14
cryptpad:14
cryptpad:14
cryptpad:14
etherpad_mypads:14

Hmokay I’m gonna try to implement some autocleanup mecanism that makes more sense than the current stuff … but not gonna be available until yunohost 4.3.x

5 Likes

Cool, thanks a lot! Something I can do in the meantime? Remove unused versions?

Yes I think you could the “true” list of used versions (and apps) with something like

grep -nr "nodejs_version:" /etc/yunohost/apps/*/settings.yml

And then you could remove unused versions

Note that sometimes you may see for example version “14” or “12”, and this should in fact correspond to something like /opt/node_n/n/versions/node/14 which should be a symlink to the latests 14.x.y version … But other versions (not pointed by a symlink) should be removable

2 Likes

Thanks a lot! In my case it is only version 14 used by Cryptpad and Etherpad:

grep -nr "nodejs_version:" /etc/yunohost/apps/*/settings.yml
/etc/yunohost/apps/cryptpad/settings.yml:10:nodejs_version: '14'
/etc/yunohost/apps/etherpad_mypads/settings.yml:19:nodejs_version: '14'

EDIT: Removing went well, now 20 GB free! :smiley:

1 Like

(app packaging note)

FYI, in the upgrade script, in case the app requires a newer NodeJS version the older one is not removed. I ended up using this bit of code:

# $nodejs_version defined in scripts/_common.sh
if [ $(ynh_app_setting_get --app=$app --key=nodejs_version) != $nodejs_version ]; then
	ynh_remove_nodejs
	ynh_install_nodejs --nodejs_version=$nodejs_version
fi

But maybe we could improve the helpers themselves.

Thanks fot the tip, it was usefull as my /usr/local/n/versions/node has all upgrades since 12 and up to 14 packages and uses up to 2.3Gb, while /opt/node_n is 930Mb.

# lsb_release  -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 10 (buster)
Release:	10
Codename:	buster
yunohost -v
yunohost: 
  repo: stable
  version: 4.3.6.2
yunohost-admin: 
  repo: testing
  version: 4.3.4.1
moulinette: 
  repo: stable
  version: 4.3.3.1
ssowat: 
  repo: stable
  version: 4.3.3.1
# grep -nr "nodejs_version:" /etc/yunohost/apps/*/settings.yml
/etc/yunohost/apps/etherpad_mypads/settings.yml:19:nodejs_version: '14'

So i did proceed to remove the old versions that where storaged under /usr/local/n/versions/node

I finally found that is nodejs eating all my disk space, and after found this useful topic.
Thanks fort that tip, 5GB could be removed, and keep version 16.
/etc/yunohost/apps/peertube/settings.yml:18:nodejs_version: '16'

Just a question…
To remove old version, can i just delete with rm -R those folders, or a special command must be used ?

This thread still save lifes :sweat_smile: Thank you for the insights !

Do we need to push it somewhere in the doc ? Or ynh_11 will make it obsolete ?

1 Like

Hello,
I am running into the same disk space issue : node takes 5.7 GB (in /usr/local/n) + 3.1 GB (in /opt/node_n) = 8.8 Gb (!!) while it seems none of my current yunohost app uses it :

grep -nr “nodejs_version:” /etc/yunohost/apps/*/settings.yml
returns nothing.

  1. Can I safely remove node (my main app that I absolutely do not want to break is NextCloud) ? Is there a way to check whether something else (a Nextcloud app ?) uses Node ?
  2. How can I remove all the (over 50!!! from 10.21.0 to 16.20.1) installed versions ? I guess I could use an apt remove command to remove it all… If I want to keep the latest version of Node to be safer, can I simply remove the older versions using a simple rm -R folders like suggested by @makotoworkshop ?

Thanks a lot for your help !

1 Like