Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tutorial] Installing nodejs and npm #287

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
105 changes: 105 additions & 0 deletions learning/dashboard/group9/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# How to install and setup NodeJS and npm?
- **step 1:**
Open the Terminal on your Ubuntu system. You can do this by pressing the **"Ctrl+Alt+T"** keys simultaneously.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Use code block to represent commands or keys
for ex: Ctrl+Alt+T

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok done

- **step 2:**
Update your package list by typing the following command in the Terminal:

`sudo apt-get update`
- **step3:**
Install Nodejs using the following command:

`sudo apt get install node js`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? I don't think this will work. is the package node js ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, there is no space in between
we will do the required changes

- **step4:**
Check if Node.js is installed by typing the following command:

`node -v`

This will display the version number of Node.js installed on your system.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding example output of the commands. this will help people understand if the command has executed correctly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will surely add some screenshorts

- **step5:**
Install NPM (Node Package Manager) by typing the following command:

`sudo apt-get install npm`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually installing the NodeJS package installs npm alongwith. Please check if this is correct.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

- **step6:**
Check if NPM is installed by typing the following command:

`npm -v`
- **step7:**
If you encounter any issues with the installation, you can try updating the package list again by typing the following command:

`sudo apt-get update`

Then repeat steps 3-6.
## Steps to update the nodejs and npm versions

- **step 1:**
Open the Terminal on your Ubuntu system.
- **step 2:**
Check the currently installed versions of Node.js and NPM by typing the following commands:

`node -v npm -v`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two separate commands usually need to be separated with &&

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

- **step3:**
To update Node.js, you can use the Node Version Manager (nvm) tool. If you do not have nvm installed, you can install it using the following command:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this section should contain steps to update NodeJS and NPM without using NVM.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the question, it was mentioned with using nvm, we will surely add without using nvm too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Install appropriate version of NodeJS and Npm based on the OS and version
    • How to update the NodeJS and npm versions -> This is the current section. Thisis without NVM
    • How to manage multiple versions of NodeJS using nvm -> This is the next section.



curl -o- [https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh](https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh) | bash
- **step4:**
Once nvm is installed, you can use it to install the latest version of Node.js by typing the following command:

`nvm install node`

This will install the latest version of Node.js. You can verify the version by typing the following command:

`node -v`
- **step5:**
To update NPM to the latest version, you can use the following command:

`npm install -g npm@latest`

This will install the latest version of NPM globally. You can verify the version by typing the following command:

`npm -v`

If you want to update NPM for a specific project, you can navigate to the project directory and run the above command without the -g flag.
## How to manage multiple versions of node.js and npm using nvm

- **Step1:**
Install nvm on your Ubuntu system by running the following command in your terminal:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be repeated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah will surely check


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

This will download and install the latest stable version of nvm.
- **Step2:**
Once nvm is installed, you can use it to install and manage different versions of Node.js by running the following command:

`nvm install <node_version>`

Replace **<node_version>** with the version of Node.js you want to install, such as "14.18.1". This will download and install the specified version of Node.js.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding some info about LTS versions of NPM and how to install / use them.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


- **Step3:**
use a specific version of Node.js, you can run the following command:

`nvm use <node_version>`

This will set the specified version of Node.js as the active version.

- **Step4:**
You can also set a default version of Node.js by running the following command:

`nvm alias default <node_version>`

This will set the specified version of Node.js as the default version that will be used when you open a new terminal window.

- **Step5:**
To check the currently installed versions of Node.js, you can run the following command:

`nvm ls`

This will show a list of all the installed versions of Node.js.
- **Step6:**
To uninstall a specific version of Node.js, you can run the following command:

`nvm uninstall <node_version>`

Replace **<node_version>** with the version of Node.js you want to uninstall.

With these steps, you can manage multiple versions of Node.js and npm on Ubuntu using nvm.