Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apt-get permission error on node.js setup

I am trying to install node.js 7 on ubuntu. on running the command

curl -sL https://deb.nodesource.com/setup_7.x | bash -

or

sudo curl -sL https://deb.nodesource.com/setup_7.x | bash -

i get the following error:

## Installing the NodeSource Node.js v7.x repo...


## Populating apt-get cache...

+ apt-get update
Reading package lists... Done
W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
Error executing command, exiting

I have also run:

apt-get update

this again results in the error above, however when i run sudo apt-get update there is no error but again on running the first two commands give error again.

i have tried to autoremove purge and upgrade but still the problem persists. any help will be much appreciate

like image 517
Kanishka Choudhury Avatar asked May 17 '26 16:05

Kanishka Choudhury


1 Answers

By running

sudo curl -sL https://deb.nodesource.com/setup_7.x | bash -

You were running bash as yourself, and curl as root.and the owner of the bash process (you) didn't have rights to write to /var/lib/apt/lists/partial.
You can try using :

sudo curl -sL https://deb.nodesource.com/setup_7.x | sudo bash  -

You can check this article for more information.

like image 84
Purple Haze Avatar answered May 19 '26 09:05

Purple Haze