You can download a Node module using the npm install
command in your terminal.
Using npm Install
- Open your terminal or command prompt.
- Navigate to the directory where you want to install the module. You can use the
cd
command to change directories. - Type
npm install <module-name>
and press Enter. Replace<module-name>
with the name of the module you want to download. For example, to install theexpress
module, you would typenpm install express
. - npm will download and install the module and its dependencies. You can verify that the module is installed by checking the
node_modules
folder in your project directory.
Example
# Navigate to your project directory
cd my-project
# Install the express module
npm install express
Additional Notes
- You can install modules globally using the
-g
flag. This will install the module in your system's global node modules directory, making it available to all your projects. - You can specify a specific version of a module by using the
@
symbol followed by the version number. For example,npm install [email protected]
will install version 4.17.1 of theexpress
module.