如何在FreeBSD 12上安装Node.js 10 LTS&NPM

时间:2020-02-23 14:33:17  来源:igfitidea点击:

如何在FreeBSD 12上安装Node.js 10 LTS.

Node.js是一个流行的免费和开源服务器端编程语言,它在各种平台上运行(Linux,Windows,Unix,MacOS)。
编号为"dubnium"的节点10 lts。

在FreeBSD 10上安装Node.js 10 LTS

Node.js是一个在Chrome的V8 JavaScript引擎上构建JavaScript运行时,可轻松构建快速,可扩展的网络应用。
在FreeBSD 12上安装Node.js 10.x LTS,使用 pkg包管理器。

请参阅FreeBSD 12上可用的节点10版本,使用:

$su 
# pkg search node-10
node-10.11.0                   V8 JavaScript for client and server

从输出中,我们可以看到我们有节点 10.11.0可在FreeBSD存储库上使用。
使用命令安装它:

# pkg install node-10.11.0
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 3 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
	node: 10.11.0
	c-ares: 1.14.0_1
	libuv: 1.23.1
Number of packages to be installed: 3
The process will require 32 MiB more space.
6 MiB to be downloaded.
Proceed with this action? [y/N]: y

在提示时 y/n确认,按Y.以下是安装示例输出

[1/3] Fetching node-10.11.0.txz:  85%    5 MiB 278.5kB/s    00:03 ETA
[1/3] Fetching node-10.11.0.txz: 100%    6 MiB 125.0kB/s    00:49    
[2/3] Fetching c-ares-1.14.0_1.txz: 100%  122 KiB 124.7kB/s    00:01    
[3/3] Fetching libuv-1.23.1.txz: 100%   99 KiB 101.3kB/s    00:01    
Checking integrity... done (0 conflicting)
[1/3] Installing c-ares-1.14.0_1...
[1/3] Extracting c-ares-1.14.0_1: 100%
[2/3] Installing libuv-1.23.1...
[2/3] Extracting libuv-1.23.1: 100%
[3/3] Installing node-10.11.0...
[3/3] Extracting node-10.11.0: 100%
Message from node-10.11.0:
Note: If you need npm (Node Package Manager), please install www/npm.

安装的Node.js版本可以确认:

# node --version
v10.11.0

有关依赖性的包的更多信息可以从中看到 pkg info输出。

# pkg info node-10.11.0
node-10.11.0
Name           : node
Version        : 10.11.0
Installed on   : Thu Dec 13 20:17:11 2016 UTC
Origin         : www/node
Architecture   : FreeBSD:12:amd64
Prefix         : /usr/local
Categories     : www
Licenses       : MIT
Maintainer     : Hyman@theitroad
WWW            : https://nodejs.org/
Comment        : V8 JavaScript for client and server
Options        :
	BUNDLED_SSL    : on
	DOCS           : on
	DTRACE         : on
	NLS            : on
Shared Libs required:
	libicudata.so.62
	libcares.so.2
	libnghttp2.so.14
	libicuuc.so.62
	libicui18n.so.62
	libuv.so.1
Annotations    :
	FreeBSD_version: 1200086
	repo_type      : binary
	repository     : FreeBSD
Flat size      : 30.8MiB
Description    :
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript
engine. Node.js uses an event-driven, non-blocking I/O model that
makes it lightweight and efficient. Node.js' package ecosystem,
npm, is the largest ecosystem of open source libraries in the world.
WWW: https://nodejs.org/

安装节点包管理器

安装Node.js 10后,可以安装将管理节点包的NPM。

# pkg install npm
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 2 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
	npm: 6.4.1
	gmake: 4.2.1_2
Number of packages to be installed: 2
The process will require 18 MiB more space.
3 MiB to be downloaded.
Proceed with this action? [y/N]: y
[1/2] Fetching npm-6.4.1.txz: 100%    3 MiB 211.5kB/s    00:15    
[2/2] Fetching gmake-4.2.1_2.txz: 100%  381 KiB  65.1kB/s    00:06    
Checking integrity... done (0 conflicting)
[1/2] Installing gmake-4.2.1_2...
[1/2] Extracting gmake-4.2.1_2: 100%
[2/2] Installing npm-6.4.1...
[2/2] Extracting npm-6.4.1: 100%

通过安装来测试NPM PM2Node.js的进程管理器

# npm install pm2 -g
/usr/local/bin/pm2 -> /usr/local/lib/node_modules/pm2/bin/pm2
/usr/local/bin/pm2-dev -> /usr/local/lib/node_modules/pm2/bin/pm2-dev
/usr/local/bin/pm2-docker -> /usr/local/lib/node_modules/pm2/bin/pm2-docker
/usr/local/bin/pm2-runtime -> /usr/local/lib/node_modules/pm2/bin/pm2-runtime
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Hyman@theitroad (node_modules/pm2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for Hyman@theitroad: wanted {"os":"darwin","arch":"any"} (current: {"os":"freebsd","arch":"x64"})
+ Hyman@theitroad
added 313 packages from 243 contributors in 35.691s