Angular CLI – Environment Setup

Angular CLI - Environment setup

To work with Angular CLI Environment setup, we need to have Node installed on our system. Let us understand the environment setup required for Angular CLI in detail.

Download Node.js archive

Download the latest version of Node.js installable archive file from Node.js Downloads, which is available at https://nodejs.org/download/. At the time of writing this tutorial, the versions available on the different OS are listed below −

OSArchive name
Windowsnode-v6.3.1-x64.msi
Linuxnode-v6.3.1-linux-x86.tar.gz
Macnode-v6.3.1-darwin-x86.tar.gz
SunOSnode-v6.3.1-sunos-x86.tar.gz

Installation on UNIX/Linux/Mac OS X, and SunOS

Based on your OS architecture, download and extract the archive node-v6.3.1-osname.tar.gz into /tmp, and then, finally move extracted files into/usr/local/nodejs directory.

For example −

$ cd /tmp

$ wgethttp://nodejs.org/dist/v6.3.1/node-v6.3.1-linux-x64.tar.gz

$ tar xvfz node-v6.3.1-linux-x64.tar.gz

$ mkdir -p /usr/local/nodejs

$ mv node-v6.3.1-linux-x64/*/usr/local/nodejs

Add /usr/local/nodejs/bin to the PATH environment variable.

OSOutput
Linuxexport PATH=$PATH:/usr/local/nodejs/bin
Macexport PATH=$PATH:/usr/local/nodejs/bin
FreeBSDexport PATH=$PATH:/usr/local/nodejs/bin

Installation on Windows

Use the MSI file and follow the prompts to install the Node.js. By default, the installer uses the Node.js distribution in C:\Program Files\nodejs.

The installer should set the C:\ProgramFiles\nodejs\bin directory in the windows PATH environment variable. Restart any open command prompts for the change to take effect.

Verify installation: Executing a File

Create a js file named main.json your machine (Windows or Linux) having the following code −

/* Hello, World! program in node.js */
console.log("Hello, World!")

The link for the live demo is https://www.Adglob.com/execute_nodejs_online.php.

Now, execute the main.js file using Node.js interpreter to see the result −

$ node main.js

If everything is fine with your installation, this should produce the following result −

Hello, World!

Now, the Node is installed. You can run the following command to install Angular CLI.

npm install -g @angular/cli

Verify the installation

Now, run the following command to see the result −

$ ng --version

If everything is fine with your installation, this should produce the following result −

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / ? \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 9.1.0
Node: 12.16.1
OS: win32 x64

Angular:
...
Ivy Workspace:

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.901.0
@angular-devkit/core         9.1.0
@angular-devkit/schematics   9.1.0
@schematics/angular          9.1.0
@schematics/update           0.901.0
rxjs                         6.5.4

On Windows, in case of ng being not recognized as an internal or external command, update the system path variable to include the following path.

C:\Users\<User Directory>\AppData\Roaming\npm

Next Topic : Click Here

This Post Has 3 Comments

Leave a Reply