在Ubuntu中安装NodeJs

时间:2018-09-30 13:46:40

标签: node.js ubuntu

嗨,我正在尝试在Ubuntu 14中安装Node.js,但出现以下错误。

 E: Cannot get debconf version. Is debconf installed?
    debconf: apt-extracttemplates failed: No such file or directory
    Extracting templates from packages: 62%E: Cannot get debconf version. Is debconf installed?
    debconf: apt-extracttemplates failed: No such file or directory
    Extracting templates from packages: 100%
    dpkg: cannot scan updates directory `/var/lib/dpkg/updates/': No such file or directory
 E: Sub-process /usr/bin/dpkg returned an error code (2)

当尝试使用更新的软件进行安装时,出现以下错误。

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/aptdaemon/worker.py", line 300, in _process_transaction
    not self.is_dpkg_journal_clean()):
  File "/usr/lib/python3/dist-packages/aptdaemon/worker.py", line 1111, in is_dpkg_journal_clean
    for dentry in os.listdir(status_updates):
FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/dpkg/updates/'

3 个答案:

答案 0 :(得分:0)

以前我有这个问题,我删除了所有等于零的变量,并解决了它,也许可以尝试一下。

答案 1 :(得分:0)

使用以下命令将Node.js维护的存储库添加到Ubuntu软件包源列表中:

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

然后使用apt-get安装Node.js:

sudo apt-get install nodejs

(可选)我们可以为节点创建符号链接(出于前面提到的原因):

sudo ln -s /usr/bin/nodejs /usr/bin/node

使用此安装选项,我们得到的是Node.js和npm的较新版本:

$ node -v

$ npm -v

检查nodenpm版本

答案 2 :(得分:0)

我建议安装nvm(节点版本管理器) https://github.com/creationix/nvm

它允许您安装和使用ANY节点版本,这可能会更好,因为ubuntu绑定到一个特定版本。在Web开发中,每个项目都是使用dofferen节点准备的,因此可能有必要进行切换