简体   繁体   English

在Ubuntu中安装NodeJs

[英]Installing nodeJs in ubuntu

Hi I am trying to install nodejs in ubuntu 14 but getting following error. 嗨,我正在尝试在ubuntu 14中安装nodejs,但出现以下错误。

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)

when trying to installing with software updated I am getting following error. 尝试使用更新的软件进行安装时,出现以下错误。

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/'

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

Add the Node.js-maintained repositories to your Ubuntu package source list with this command: 使用以下命令将Node.js维护的存储库添加到您的Ubuntu软件包源列表中:

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

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

sudo apt-get install nodejs

Optionally we can create a symbolic link for node (for reasons mentioned earlier): (可选)我们可以为节点创建符号链接(出于前面提到的原因):

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

Using this install option, we end up with newer versions of Node.js and npm: 使用此安装选项,我们最终获得了更高版本的Node.js和npm:

$ node -v

$ npm -v

to check node version and npm version 检查node版本和npm版本

I suggest installing nvm (node version manager) https://github.com/creationix/nvm 我建议安装nvm(节点版本管理器) https://github.com/creationix/nvm

it allows you to install and use ANY node version, and this may be way better, because ubuntu is bound to one specific version. 它允许您安装和使用ANY节点版本,这可能会更好,因为ubuntu绑定到一个特定版本。 In web development, every project is prepared using dofferen node, so switching it might be necessary 在Web开发中,每个项目都是使用dofferen节点准备的,因此可能有必要进行切换

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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