This appendix is a practical setup guide for getting ready to follow the book’s JavaScript examples. It explains how to install the core command-line tools you’ll use throughout the rest of the book, including node, npm, and npx, and it also notes that recent Node.js releases are sufficient for the exercises. Along the way, it introduces the idea that development can happen locally on your own machine or in cloud-based environments, which can be useful for sharing projects, reproducing bugs, and keeping setups consistent across a team.
The main recommendation is to avoid installing Node.js directly and instead use a version manager, specifically fnm. A version manager makes it easy to install different Node.js releases, switch between them, and keep projects isolated from compatibility problems caused by version changes. The appendix recommends using the latest LTS release, shows how to set it as the default, and explains how to tie a project to a specific version with a .node-version file so the correct runtime can be selected manually or automatically when entering a directory.
The appendix also steps back to compare the Node.js ecosystem with nearby alternatives. It briefly describes runtimes such as Deno and Bun, emphasizing their design goals, strengths, and current compatibility tradeoffs, while noting that Node.js still dominates the broader JavaScript toolchain. It then surveys package manager alternatives to npm, including Yarn, pnpm, JSR, and Bun’s package manager, highlighting differences in speed, workspaces, dependency handling, and security. Although the book uses npm, the appendix suggests that pnpm is especially attractive for new projects because of its performance and more cautious default security model.
A.4 Summary
If you don’t want to set up Node.js on your development machine, you can use websites like CodeSandbox and StackBlitz to spin up a complete Node.js development environment directly in your browser.
Installing Node.js with fnm makes it easy to use different versions of Node.js and npm for different projects, avoiding potential compatibility issues.
Node.js is very popular but faces competition from Deno and Bun. Deno offers a more “batteries included” experience, while Bun promises faster performance.
Node.js comes with a package manager called npm, but several alternatives are available that offer faster performance and other benefits. Most notably, pnpm has been gaining traction in recent years.
FAQ
What is the main purpose of Appendix A in this book?It’s a quick start guide for installing Node.js and npm, setting up the node, npm, and npx commands, managing multiple Node.js versions, and briefly reviewing alternatives to Node.js and npm.Why does the appendix recommend using a Node.js version manager instead of downloading Node directly from the official website?A version manager lets you install and switch between multiple Node.js versions, which helps you avoid backward compatibility issues when different projects need different versions.Which Node.js version manager does the appendix use, and why?The appendix uses fnm (Fast Node Manager) because it is easy to set up, works on major platforms, and can switch Node.js versions very quickly.How do you install the latest LTS version of Node.js with fnm?After installing fnm, run fnm install --lts to install the latest Long Term Support version of Node.js.How do you make fnm use the newly installed Node.js version?Copy the version reported by the install command and run fnm use [version], then confirm it with node --version.How can you make a Node.js version the default for new shell sessions?Use fnm default [version] so that the selected LTS version is automatically used when you start a new shell session.What is the purpose of a .node-version file?It records the Node.js version for a project, making it easy to switch to the correct version automatically or manually when working in that directory.How can fnm automatically switch Node.js versions when you enter a project directory?Initialize fnm with the --use-on-cd flag in your shell startup script, and fnm will switch versions whenever you change into a directory containing a .node-version file.What are the main alternatives to Node.js mentioned in the appendix?The appendix highlights Deno and Bun as notable alternatives to Node.js.Why does the appendix still recommend Node.js and npm for most projects?Node.js has the largest ecosystem and market share, so most JavaScript libraries and tools are designed for it. The appendix also notes that npm remains the most common package manager, even though tools like pnpm and Yarn may offer advantages in speed, workspaces, and security.
pro $24.99 per month
access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!