|
Post by account_disabled on Jan 26, 2024 23:48:09 GMT -6
以下摘录自 出版的《使用 Node.js 编程》一书。您可以使用代码fccwexler在这里以 37% 的折扣购买这本书。 使用 Node.js 进行编程封面本文是关于使用 Node.js 的实用介绍。我们将重新安装 Node.js,了解 npm,然后构建一个 Node.js 模块并直接开始初始化 Web 服务器。欢迎大家在家跟着阅读哦! 安装 Node.js Node.js 越来越受欢迎并得到越来越多的支持。因此,要下载的新版本的部署非常频繁,因此保持最新版本的最新状态非常重要,以了解它们如何使您正在构建的应用程序受益或以其他方式影响。在撰写本文时,要下载的 Node.js 版本为 7.6 或更高版本。 注意:Node.js 7.6 版本支持 ES6 语法。ES6 (ECMAScript 2015) 是 JavaScript 的最新更新,对定义变量、函数和 OOP 代码进行了语法改进。为了跟上 JavaScript 的更新,请随着开发的进展下载 Node.js 的最新稳定版本。 有多种方法可以下载和安装 Node.js,所有这些方法都列在Node.js 主站点上。 Learn to Code with JavaScript 由于 Node.js 独立于平台,因此您可以在 macOS、Windows 或 Linux 上下载并安装它并获得完整功能。 安装 Node.js 最简单的方法是转到下载链接并按照说明 WhatsApp 号码数据 和提示下载最新版本 Node.js 的安装程序。 注意:当您安装 Node.js 时,您还会获得 npm,这是外部库(其他人编写的多个代码文件)的 Node.js 生态系统,可以将其导入到您未来的项目中。您将在下一节中了解有关 npm 的更多信息。 npm 安装程序 图 1. Node.js 安装程序页面 下载安装程序文件后,从浏览器的下载面板或计算机的下载文件夹中双击该文件。安装程序将打开一个如图 1 所示的新窗口,并将所有必需的文件和核心 Node.js 库写入您的系统。系统可能会要求您接受许可协议或授予安装程序将 Node.js 安装到您的计算机上的权限。按照提示点击完成安装。 安装 图 2. Node.js 写入您的机器 终端和你的路径 您将主要在计算机终端上工作,终端是内置软件,用于在没有图形界面的情况下在计算机上导航和运行命令。本书教授如何使用 Unix 终端 (Bash) 命令。Windows 用户可以使用 Windows 的 CMD 终端窗口(您可能需要在整本书中查找等效命令)。您可以参考此表来比较 Windows 和 Unix 命令。为了让 Windows 上的操作变得更简单,您可以从 git-scm.com 下载并安装一个名为 GitBash 的附加 Bash 终端。 Learn to Code with JavaScript 记下 Node 和 npm 版本在计算机上的安装位置。此信息显示在安装程序的最后一个窗口中。安装程序尝试将这些目录位置添加到系统的 PATH 中。 您计算机的 PATH 变量是终端查找开发中使用的资源的第一个位置。将其视为计算机的索引,用于快速查找所需的工具。通过将这些工具的原始文件路径或目录位置添加到 PATH 变量,终端在查找它们时不会出现任何问题。
|
|