node.js设置中的apt-get权限错误

Aci*_*cid 2 ubuntu apt node.js

我想在ubuntu上安装node.js 7.在运行命令

curl -sL https://deb.nodesource.com/setup_7.x | bash -
Run Code Online (Sandbox Code Playgroud)

要么

sudo curl -sL https://deb.nodesource.com/setup_7.x | bash -
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

## 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
Run Code Online (Sandbox Code Playgroud)

我也跑了:

apt-get update
Run Code Online (Sandbox Code Playgroud)

这再次导致上面的错误,但是当我运行时sudo apt-get update 没有错误但是再次运行前两个命令再次给出错误.

我试过autoremove purge,upgrade但问题仍然存在.任何帮助都会非常感激

Pur*_*aze 12

通过运行

sudo curl -sL https://deb.nodesource.com/setup_7.x | bash -
Run Code Online (Sandbox Code Playgroud)

你正在以自己的身份运行bash,并以root身份卷曲.而bash进程的所有者(你)没有权限写入/ var/lib/apt/lists/partial.
您可以尝试使用:

sudo curl -sL https://deb.nodesource.com/setup_7.x | sudo bash  -
Run Code Online (Sandbox Code Playgroud)

您可以查看此文章以获取更多信息.