Node.js Setting Up Development Environment

Installing Node.js and npm:

Node.js comes with npm, the Node Package Manager, which is essential for managing project dependencies.

Let's see how to install Node.js and npm:

Using Node Version Manager (nvm):

nvm allows you to manage multiple versions of Node.js on the same machine.

Installation on macOS and Linux:

Install nvm:

                        
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
                        
                    

Load nvm:

                        
                        export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
                        
                    

Install Node.js:

                        
                        nvm install node
                        
                    

Verify installation:

            
            node -v
npm -v
            
        

Installation on Windows:

Install nvm for Windows: Download and install from the nvm-windows repository.

Install Node.js:

            
nvm install latest
nvm use latest
            
        

Verify installation:

            
            node -v
npm -v