可以在Linux虚拟机VirtualBox里运行FreeBSD 12并在系统中安装Node.js 10 LTS和NPM(Node Package Manager),以下是安装的具体方法。有一点要指出的是,Node.js v11.0.0发布下载,不再支持FreeBSD 10系统。
在FreeBSD 10上安装Node.js 10 LTS的方法 要在FreeBSD 12上安装Node.js 10.x LTS,请使用pkg package manager。 请参阅FreeBSD 12上提供的可用节点10版本,使用: $ su - # pkg search node-10 node-10.11.0 V8 JavaScript for client and server 从输出中,你可以看到我们在FreeBSD存储库上提供了Node 10.11.0,使用以下命令安装它: # 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 infooutput可以看到有关包等依赖关系的更多信息,运行pkg info node-10.11.0命令:
安装Node Package Manager(NPM) 安装Node.js 10后,你可以安装可帮助你管理Node packages的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% 通过为Node.js安装PM2进程管理器来测试你的npm: # 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: fsevents@1.2.4 (node_modules/pm2/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"freebsd","arch":"x64"}) + pm2@3.2.3 added 313 packages from 243 contributors in 35.691s 至此,已成功在FreeBSD 12上安装Node Package Manager(NPM),这时可以使用Node.js 10进行开发了。
相关主题 |