Welcome to our guide on how to install Node.js 10 LTS on FreeBSD 12. Node.js is a popular free and open source server-side programming language which runs on various platforms (Linux, Windows, Unix, MacOS). The Node 10 LTS codenamed “Dubnium“.  will remain supported until April 2020.

Earlier on I had written other articles on FreeBSD 12:

How to Install VIM Text Editor on FreeBSD 12

How to Install MariaDB 10.3 on FreeBSD 12

How to Install PHP 7.2 on FreeBSD 12

Installing Node.js 10 LTS on FreeBSD 10

Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine for easily building fast, scalable network applications. To install Node.js 10.x LTS on FreeBSD 12, use pkg package manager.

See available Node 10 version available on FreeBSD 12, use:

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

From the output, you can see we have Node 10.11.0 available on FreeBSD repository. Install it using the command:

# 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

When prompted for a y/n confirmation, press y. Below is the installation sample output

[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 version installed can be confirmed with:

# node --version
v10.11.0

More information about the package like dependencies can be seen from the pkg infooutput.

# pkg info node-10.11.0
node-10.11.0
Name           : node
Version        : 10.11.0
Installed on   : Thu Dec 13 20:17:11 2018 UTC
Origin         : www/node
Architecture   : FreeBSD:12:amd64
Prefix         : /usr/local
Categories     : www
Licenses       : MIT
Maintainer     : [email protected]
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/

Install Node Package Manager

After installing Node.js 10, you can install NPM that will help you manage Node packages.

# 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%

Test your npm by installing PM2 process Manager for Node.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: [email protected] (node_modules/pm2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"freebsd","arch":"x64"})

+ [email protected]
added 313 packages from 243 contributors in 35.691s

Enjoy developing with Node.js 10 on FreeBSD 12.