Home > Article > Web Front-end > nodejs npm installation tutorial
Node.js is an open source JavaScript running environment that can run JavaScript code on the server side. Node.js has strong support for the ECMAScript standard and a wealth of modules and tools to help developers efficiently build, test and maintain web applications.
One of the most important tools in Node.js is npm (Node Package Manager), which is a module manager that can help developers easily install, upgrade and manage dependencies. This article will explain how to install Node.js and npm on Windows, Mac and Linux.
1. Install Node.js
Before you start installing npm, you need to install Node.js first. The official Node.js website provides installation programs for Windows, Mac and Linux.
Windows installation:
Mac installation:
Linux installation:
sudo apt-get update
sudo apt -get install nodejs
2. Install npm
After installing Node.js, npm will also be installed together. You can enter the npm -v command in the terminal to check whether npm is installed successfully.
If npm fails to install or needs to be upgraded, you can install or upgrade it through the following command:
npm install npm -g
This will install the latest version globally npm version.
3. Use npm
Enter the project folder on the console and enter the following command:
npm init
Enter relevant information as prompted on the command line, such as project name, author, version number, etc.
You can enter the following command on the command line to install the npm package:
npm install
For example, the command to install the Express framework is as follows:
npm install express
You can enter the following command on the command line to Uninstall the npm package:
npm uninstall
For example, the command to uninstall the Express framework is as follows:
npm uninstall express
You can enter the following command on the command line to update the npm package:
npm update
For example, the command to update the Express framework is as follows :
npm update express
You can enter the following command on the command line to view the installed npm package:
npm list
Alternatively, you can view the details of the specified module through the following command:
npm view
For example, view the details of the Express framework The command is as follows:
npm view express
Summary
This article introduces how to install Node.js and npm on Windows, Mac and Linux, and introduces how to use npm Manage dependencies. npm is a must-have tool for any developer who wants to build web applications using Node.js. Through the steps described in this article, I believe readers can successfully install Node.js and npm, and quickly master the basic usage of npm.
The above is the detailed content of nodejs npm installation tutorial. For more information, please follow other related articles on the PHP Chinese website!