I'm trying to install node.js version 12 on my Ubuntu 19.10 laptop by following the instructions here.

When I execute the curl command I get an error about a locked directory:

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

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

## Populating apt-get cache...

+ apt-get update
Reading package lists... Done
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've looked to see if there's an apt-get task and rebooted my machine, but no joy.

Does anyone have a suggestion on how to get past this?


"Permission denied" usually means you're not root. But you always need superuser rights to install software.

Try this:

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

Notice the | sudo bash command at the end. That will run the install script as root.

  • Exactly right. Thank you so much! I'm still learning Ubuntu. Your expertise is greatly appreciated. – duffymo Nov 9 '19 at 21:38
  • It's something I tend to forget myself. In time you get used to it: Ah "Permission denied" I probably forgot sudo... ;) – Friederike Nov 9 '19 at 21:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.