Install Express JS Node Js in Mac OS.
In this article, you’ll use Homebrew to build up a Node.js programming environment on your local Mac, and then try it out by writing a small Node.js program.
Node and the NPM package management are installed as a pair via binary packages, installers, operating system package managers, or source code (as shown in the following sections). NPM then instals Express as a dependency of each of your Express web applications (along with other libraries like template engines, database drivers, authentication middleware, middleware to serve static files, etc.)
NPM may also be used to install the Express Application Generator (globally), which is a useful tool for quickly constructing skeletal Express web apps that follow the MVC design. Because you don’t need to utilise the application generator to develop Express apps or construct Express apps with the same architectural layout or dependencies, it’s optional. We’ll utilise it, nevertheless, because it makes travelling around easier.
What operating systems are supported?
Node can operate on Windows, macOS, Linux, Docker, and other platforms. The nodejs Downloads page has a comprehensive list. Almost any personal computer should be capable of running Node while under development. Express is written in Node and so may operate on any platform that supports Node.
Text editors or integrated development environments (IDEs) for editing code, as well as source control management tools like Git for properly managing multiple versions of your code, are all part of a typical development environment. We’re presuming you already have these kinds of programmes installed (in particular a text editor). We give setup instructions for Windows, macOS, and Ubuntu Linux in this article.
What version of Node/Express Should you use?
In general, you should use the most recent LTS (long-term supported) release because it will be more reliable than the “current” release while still containing recent features (and is still being actively maintained). If you need a feature that isn’t available in the LTS version, you should use the current release.Always use the most recent version of Express.
What about databases and other dependencies?
Database drivers, template engines, authentication engines, and other dependencies are part of the application and are imported into the environment via the NPM package manager. We’ll go through them in more detail in future app-specific articles.
Installing Express JS Node Js in Mac OS.
You must first install Nodejs and the Node Package Manager (NPM) on your operating system before you can utilise Express. The sections that follow will show you how to install Nodejs Long Term Supported (LTS) on Ubuntu Linux 20.04, macOS, and Windows 10.
In this article, you’ll use Homebrew to build up a Node.js programming environment on your local Mac, and then try it out by writing a small Node.js programme.
Step 1 — Using the macOS Terminal
To install Node.js and run numerous tasks relevant to developing Node.js applications, you’ll need the command line. The command line is an alternative to using your computer’s graphical interface. You’ll type commands as text and receive text-based feedback instead of clicking buttons with your mouse. The command line. Often known as a shell, is a useful tool for software engineers because it allows them to automate many of the processes they perform on their computers on a regular basis.
You’ll use the Terminal application included with macOS to get to the command-line interface. You can discover it by opening Finder. Heading to the Applications folder, and then to the Utility folder. just like any other application. To open the Terminal application, double-click it from this location. You may also utilize Spotlight to find what you’re looking for.
You’ll utilize the command line to install Node.js and conduct other Node. js-related operations. The command line is a method of interacting with your computer that is not graphical. Instead of using your mouse to click buttons, you’ll type commands and receive text-based feedback. The command line, often known as a shell, allows you to automate many of the actions you perform on your computer on a daily basis. It is a crucial tool for software engineers.
You’ll use macOS’ Terminal application to go to the command line interface. You can find it by opening Finder. Heading to the Applications folder, and then to the Utilities folder, just like any other app. Double-click the Terminal application to launch it. You can also utilise Spotlight.
Step 2 — Installing Xcode’s Command Line Tools
Xcode is a software development environment (IDE) for macOS that includes a number of software development tools. You don’t need Xcode to write Node.js apps. however the Command Line Tools package in Xcode is required by Node.js and several of its components.
To download and install these components, use this command in the Terminal.
You’ll be asked to begin the installation, and then you’ll be asked to accept a software licence once again. The tools will then download and install themselves.
We’re now ready to install Homebrew. A package manager that will allow us to install the most recent version of Node.js.
Step 3 — Installing and Setting Up Homebrew
While macOS’ command-line interface has a lot of the same features as Linux and other Unix systems. It comes without a competent package manager. A package manager is a set of software tools for automating programme installation, configuration, and upgrades. They store all of the software they install in one place and can keep all of the software packages. homebrew is a free and open-source software package management system for macOS that makes program installation a breeze. To install the most latest version of Node.js, we’ll utilise Homebrew.
Curl downloads the script, which is then run by the Ruby interpreter included with macOS, kicking off the Homebrew installation process.
The installation script will explain what it will perform and ask if you are sure you want to proceed. This allows you to see exactly what Homebrew will do to your system before allowing it to run. It also ensures that you have all of the necessary conditions in place before proceeding.
During the procedure, you’ll be asked to enter your password. Your keystrokes, however, will not appear in the Terminal window when you type your password. This is a security feature that you’ll notice when you’re prompted for a password on the command line. Your keystrokes are being recorded even if you can’t see them.
Step 4 — Installing Node.js
You can install a wide selection of apps and developer tools with Homebrew installed. It will be used to set up Node.js and its dependencies.
With the brew search command, you may search for anything you can install with Homebrew, but to keep things simple, let’s look for packages relevant to Node.js:
In your Terminal, you should see something like this. Many dependencies will be installed by Homebrew, but Node.js will be downloaded and installed in the end.
Apart from Node.js, Homebrew also instals a few related tools, such as npm, which makes it simple to install and update Node.js libraries and packages in your own projects.
Step 5 — Creating a Simple Program
Let’s make a straightforward “Hello, World” programme. This will ensure that our environment is up and running, as well as familiarise you with writing and running Node.js programmes.
By using CTRL+X, you can exit the editor. Then, when requested to save the file, press y. You’ll be taken back to your original prompt.
Now type the following command to start the application.
This small software verifies that your development environment is up and running. This environment can be used to continue learning Node.js and create larger, more interesting projects.