npm下载安装教程_npm下载,安装和使⽤教程
npm下载安装教程
nodejs is a popular javascript platform and framework which provides server and client-side libraries. What makes nodejs so successful is its package manager named npm or nodejs package manager. npm provides easily install, update and remove packages and load libraries according to the application configuration.
nodejs是流⾏的javascript平台和框架,提供服务器和客户端库。 使nodejs如此成功的原因是其名为npm软件包管理器或nodejs软件包管理器。 npm可根据应⽤程序配置轻松安装,更新和删除软件包以及加载库。
为Ubuntu,Debian,Mint,Kali安装Npm软件包 (Install Npm Package For Ubuntu, Debian, Mint, Kali)
We can install npm package with the apt command where Ubuntu, Debian, Mint, Kali distributions support.
我们可以使⽤apt命令安装npm软件包,其中⽀持Ubuntu,Debian,Mint,Kali发⾏版。
$ sudo apt install npm
Install Npm Package For Ubuntu, Debian, Mint, Kali
为Ubuntu,Debian,Mint,Kali安装Npm软件包
为Fedora,CentOS,RedHat安装Npm软件包(Install Npm Package For Fedora, CentOS, RedHat)
For yum based distributions we will use yum or dnf command like below where we will install npm package.
对于基于yum的发⾏版,我们将使⽤yum或dnf命令(如下所⽰)在其中安装npm软件包。
$ sudo yum install npm
OR
要么
$ sudo dnf install npm
Install Npm Package For Fedora, CentOS, RedHat
为Fedora,CentOS,RedHat安装Npm软件包
打印npm⼀般帮助信息(Print npm General Help Information)
npm command provides different type of commands or options in order to manage nodejs packages. We can get general information about these command with the -h option.
npm命令提供了不同类型的命令或选项,以管理nodejs软件包。 我们可以使⽤-h选项获得有关这些命令的常规信息。
$ npm -h
Print npm General Help Information
打印npm⼀般帮助信息
获取npm的特定命令或选项帮助(Get Specific Command or Option Help For npm)
In the previous example, we have listed generic information about the npm commands and options. We may need a more detailed help about these commands or options which can be listed with the COMMAND -h . In this example, we will list detailed help about the search command.
在前⾯的⽰例中,我们列出了有关npm命令和选项的⼀般信息。 关于这些命令或选项,我们可能需要更详细的帮助,这些命令或选项可以与COMMAND -h⼀起列出。 在此⽰例中,我们将列出有关search命令的详细帮助。
$ npm search -h
Get Specific Command or Option Help For npm
获取npm的特定命令或选项帮助
使⽤npm搜索A软件包(Search For A Packages with npm)
We can search for a specific package for installation with the search command or option. In this example, we will search the term angular.
我们可以使⽤search命令或选项search要安装的特定软件包。 在此⽰例中,我们将搜索术语angular 。
$ npm search angular
Search For A Packages with npm
使⽤npm搜索A软件包
We can see that search results are printed and listed in a structured column. This search results will present the following information.
我们可以看到搜索结果已打印并列在结构化列中。 该搜索结果将显⽰以下信息。
NAME is the package full name like angular, angular-strap etc.
NAME是软件包的全名,例如angular , angular-strap等。
DESCRIPTION is the info about the package what is it.
DESCRIPTION是有关包装信息的信息。
AUTHOR is the package creator’s name or team name.
AUTHOR是包创建者的名称或团队名称。
DATE is the last time the package is updated.
DATE是软件包的最后更新时间。
VERSION is the version number of the package which is the latest.
VERSION是软件包的最新版本号。
KEYWORDS are some tags that describe and related to the package.
KEYWORDS是⼀些描述软件包并与软件包相关的标签。
了解更多如何在Linux和Windows上更新Npm?
使⽤npm安装单个软件包 (Install Single Package with npm)
We can install packages with the install npm command or options by providing the package full name. In this example, we will install the package named angular.
我们可以通过提供软件包全名来使⽤install npm命令或选项来安装软件包。 在此⽰例中,我们将安装名为angular的软件包。
$ npm install angular
Install Single Package with npm
使⽤npm安装单个软件包
We can see that after the package installation is complete the installed package name with is angular and the version installed which is 1.7.8 are printed to the console.
我们可以看到,在软件包安装完成后,已安装的软件包名称(带有angular和已安装的版本1.7.8被打印到控制台。
使⽤npm在package.json中安装所有项⽬依赖项 (Install All Project Dependencies in package.json with npm)
package.json provides the list of the packages which is required for a project. In order to run this proj
ect, the packages should be installed. npm command can install packages listed in this package.json easily.
package.json提供了项⽬所需的软件包列表。 为了运⾏此项⽬,应安装软件包。 npm命令可以轻松安装此package.json列出的软件包。
{
"name": "node-js-sample",
"version": "0.2.0",
"description": "A sample Node.js app using Express 4",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"express": "^4.13.3"
如何下载javascript},
"engines": {
"node": "4.0.0"
},
"repository": {
"type": "git",
"url": "github/heroku/node-js-sample"
},
"keywords": [
"node",
"heroku",
"express"
],
"author": "Mark Pundsack",
"contributors": [
"Zeke Sikelianos <> (zeke.sikelianos)"
],
"license": "MIT"
}
We can simply use install command which will automatically look for package.json and install the required packages.
我们可以简单地使⽤install命令,它将⾃动查package.json并安装所需的软件包。
$ npm install
使⽤npm更新软件包 (Update Packages with npm)
Updating packages with the npm is easy as installing them. We will provide the package name we want to update to the update command or option. In this example, we will update the package named angular.
使⽤npm更新软件包就像安装它们⼀样容易。 我们将要更新的包名称提供给update命令或选项。 在此⽰例中,我们将更新名为angular的包。
$ npm update angular
更新nmp (Update nmp)
Update nmp
更新nmp
npm can install and update different JavaScript libraries. npm can also update itself like a normal package. We will use i option and provide the package name as npm like below.

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。