Chapter 2. Scripts and Modules
We used the node
command briefly in Chapter 1 to explore Node’s REPL mode and execute simple scripts. In this chapter, we’ll learn how Node loads and executes scripts modules. We’ll start by exploring more of the options, arguments, and environment variables that can be used with the node
command, and learn more about what we can do in a REPL session. Then we learn about the steps Node takes to load and execute a module.
Node CLI
The node
command has many options that can be used to customize its behavior. It also supports arguments and environment variables to further customize what it does, and to pass data from the operating system environment to Node’s process environment.
Let’s take a look. In the terminal, type:
$ node -h | less
This will output the help documentation for the command (one page at a time because we piped the output on the less
command). I find it useful to always get myself ...
Get Efficient Node.js now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.