2023年12月8日发(作者:)
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 searchcommand.
在前面的示例中,我们列出了有关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在中安装所有项目依赖项 (Install All Project Dependencies in
with npm)
provides the list of the packages which is required for a project. In order to run this project, the packages
should be installed. npm command can install packages listed in this easily.
提供了项目所需的软件包列表。 为了运行此项目,应安装软件包。 npm命令可以轻松安装此列出的软件包。
{
"name": "node-js-sample",
"version": "0.2.0",
"description": "A sample app using Express 4",
"main": "",
"scripts": {
"start": "node "
},
"dependencies": {
"express": "^4.13.3"
},
"engines": {
"node": "4.0.0"
},
"repository": {
"type": "git",
"url": "/heroku/node-js-sample"
},
"keywords": [
"node",
"heroku",
"express"
],
"author": "Mark Pundsack",
"contributors": [
"Zeke Sikelianos <> ()"
],
"license": "MIT"
}
We can simply use install command which will automatically look for and install the required packages.
我们可以简单地使用install命令,它将自动查找并安装所需的软件包。
$ 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.
npm可以安装和更新不同JavaScript库。 npm也可以像普通软件包一样进行自我更新。 我们将使用i选项,并将软件包名称提供为npm如
下所示。
$ npm i npm
Update npm
更新npm
We can see from the output that the current version is updated to the 6.9.0 .
从输出中我们可以看到当前版本已更新为6.9.0。
了解更多如何使用Npm安装Gulp
使用npm打印软件包详细信息 (Print Package Details with npm)
npm package information can be listed with the info or view command. We will also provide the package name. In this
example, we will list and print information about the angular package.
可以使用info或view命令列出npm软件包信息。 我们还将提供包裹名称。 在此示例中,我们将列出并打印有关angular包的信息。
$ npm info angular
Print Package Details with npm
使用npm打印软件包详细信息
Print Package Details with npm
使用npm打印软件包详细信息
We can see that the following information about the package is provided.
我们可以看到提供了有关该软件包的以下信息。
name is the package full name.
name是程序包的全名。
description is short information about the package.
description是有关包装的简短信息。
latest is the latest version of the package.
latest是软件包的最新版本。
readmeFilename is the name of the README.
readmeFilename是自述文件的名称。
homepage is the official home page of the package.
homepage是程序包的官方主页。
keywords is related tags and keywords with the package.
keywords是与程序包相关的标签和关键字。
license is a usage license.
license是使用许可证。
npm下载安装教程


发布评论