简体   繁体   中英

Is it safe to delete `/usr/local/bin`?

I previously used Node installed from the website, and I've recently started using nvm . I deleted /usr/local/lib/node_modules , and was about the delete /usr/local/bin as well, but noticed there were a bunch of modules in it that I didn't recognize.

What I Want To Know: Does /usr/loca/bin contain anything other than modules installed via npm i -g ? In other words, if I delete /usr/local/bin and just start re-installing all the global modules that I need via npm i -g , are there any risks to that? When I install global modules now, they get saved in ~/.nvm/versions/node/v14.15.4/lib .

Is it safe to delete /usr/local/bin ?

Absolutely not. It will destroy other applications you installed on your machine as well. It's the install path for all binaries that should survive operating system changes/upgrades. (It's a bit like asking "Is it safe to delete C:\Program Files ?" in Windows.)

You should delete only /usr/local/bin/node and all of the now-broken symlinks into /usr/local/lib/node_modules (since you deleted the folder - symlinks such as npm but possibly others as well if you globally installed any packages that provide CLIs). I'm assuming you have GNU find , then you can use the -xtype l option to find broken links:

sudo rm /usr/local/bin/node
sudo find /usr/local/bin -xtype l -delete

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM