我在VPS上安装Ubuntu 16.04。
我的框架是laravel 5.6。
在/ var / www / html
上传我的项目运行sudo apt-get install -y nodejs
此代码后,显示此错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
nodejs
0 upgraded, 1 newly installed, 0 to remove and 132 not upgraded.
Need to get 0 B/12.8 MB of archives.
After this operation, 62.5 MB of additional disk space will be used.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_TIME = "fa_IR",
LC_MONETARY = "fa_IR",
LC_ADDRESS = "fa_IR",
LC_TELEPHONE = "fa_IR",
LC_NAME = "fa_IR",
LC_MEASUREMENT = "fa_IR",
LC_IDENTIFICATION = "fa_IR",
LC_NUMERIC = "fa_IR",
LC_PAPER = "fa_IR",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory
Selecting previously unselected package nodejs.
(Reading database ... 73714 files and directories currently installed.)
Preparing to unpack .../nodejs_9.11.1-1nodesource1_amd64.deb ...
Unpacking nodejs (9.11.1-1nodesource1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up nodejs (9.11.1-1nodesource1) ...
并运行node -v
显示此错误:
node: error while loading shared libraries: libuv.so.1: cannot open shared object file: No such file or directory
如何在ubuntu 16.4上安装npm和node而不出错?
答案 0 :(得分:1)
我强烈建议您使用Node Version Manager,它也适用于许多准系统系统,并且可以让您进一步解决与该版本的Node相关的特定问题。 AFAICT您看到的特定错误与您使用的有关公共C库的特定快照16 04 (而不是16.4)有关。如果使用不同的Node版本尚未解决此问题,我建议两件事来解决这个问题:
答案 1 :(得分:0)
错误与节点无关,而与您配置错误的ubuntu无关。运行
sudo locale-gen en_US.UTF-8 #### ---> or the locale you are actually using
sudo dpkg-reconfigure locales
配置系统的区域设置。之后,卸载nodejs
sudo apt remove --purge nodejs
现在,按照nodejs' website上有关如何通过包管理器安装nodejs的建议。要安装节点,请执行以下操作:
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential
现在你有一个工作的ubuntu(至少对于相关部分)和nodejs
答案 2 :(得分:0)
尝试使用 nvm (节点版本管理器),您可以从终端安装
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
它会为您设置所有环境(比如在终端中启用节点命令,对 npm 启用相同)和 nvm 让您以非常简单的方式下载和更改设备中当前版本的Nodejs,这是一个非常好的功能,考虑到节点具有较高的更新频率。
答案 3 :(得分:0)
我通过以下任务解决了在ubuntu 18.04 Bionic上的nodejs安装:
sudo vim /etc/apt/sources.list
添加以下行:
#newer versions of the distribution.
deb http://fr.archive.ubuntu.com/ubuntu/ bionic main restricted
deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://fr.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb http://fr.archive.ubuntu.com/ubuntu/ bionic universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security universe multiverse
deb http://fr.archive.ubuntu.com/ubuntu/ bionic-updates universe multiverse
$ sudo apt更新
$ sudo apt升级
$ sudo apt install nodejs
$ node -v
$ sudo apt install npm