npm i 命令安装包时如何查看已安装包
在当今快速发展的软件开发领域,使用npm(Node Package Manager)来管理项目依赖已经成为一种常态。当我们在使用npm安装包时,如何查看已安装的包成为了许多开发者关心的问题。本文将详细介绍在npm i命令安装包时如何查看已安装包,帮助开发者更好地管理项目依赖。
1. 使用npm list命令查看已安装包
在npm i命令安装包后,我们可以使用npm list命令来查看已安装的包。这个命令可以列出当前项目中所有已安装的包,包括它们各自的版本信息。
npm list
执行上述命令后,你将看到类似如下的输出:
@types/node@14.0.29 node
express@4.17.1 express
lodash@4.17.21 lodash
这个输出表示当前项目中已安装了node、express和lodash这三个包,以及它们各自的版本信息。
2. 使用npm list -g命令查看全局已安装包
除了查看项目中的已安装包,我们还可以使用npm list -g命令来查看全局已安装的包。这个命令可以列出系统中所有全局安装的npm包。
npm list -g
执行上述命令后,你将看到类似如下的输出:
@vue/cli@4.5.6 vue-cli
typescript@4.0.5 typescript
这个输出表示系统中全局安装了vue-cli和typescript这两个包,以及它们各自的版本信息。
3. 使用npm list
如果你只想查看某个特定包的版本信息,可以使用npm list
npm list express
执行上述命令后,你将看到类似如下的输出:
express@4.17.1 express
这个输出表示当前项目中已安装了express包,以及它的版本信息。
4. 使用npm outdated命令查看已过时的包
在开发过程中,有些包可能会发布新的版本,这时我们可以使用npm outdated命令来查看哪些包已经过时。
npm outdated
执行上述命令后,你将看到类似如下的输出:
Package Current Wanted Latest Location
express 4.17.1 4.17.1 4.18.1 express
lodash 4.17.21 4.17.21 4.17.21 lodash
这个输出表示express和lodash这两个包已经过时,其中express的最新版本为4.18.1。
5. 使用npm view
如果你想了解某个包的详细信息,可以使用npm view
npm view express
执行上述命令后,你将看到类似如下的输出:
name: express
version: 4.17.1
description: Fast, unopinionated, minimalist web framework for Node.js
main: index.js
dependencies:
body-parser: ^1.19.0
cookie-parser: ^1.4.4
compress: ^1.7.4
connect: ^3.7.0
cookie-session: ^1.4.0
debug: ^4.1.1
dot-prop: ^5.2.0
engage: ^1.0.0
encodeurl: ^1.0.1
escape-html: ^1.0.5
express-serve-static-core: ^4.0.2
express-session: ^1.15.6
finalhandler: ^1.4.3
formidable: ^1.2.2
fs: ^0.0.1-security
http: ^0.0.0-security
http-errors: ^1.6.3
mime: ^1.3.4
ms: ^2.1.3
negotiate: ^1.0.0
parseurl: ^1.5.0
path-to-regexp: ^1.7.0
promise: ^8.0.0
range-parser: ^1.2.0
send: ^0.17.1
serve-static: ^1.13.1
type-is: ^1.6.16
util-deprecate: ^1.0.2
vary: ^1.1.0
view: ^1.1.4
vm: ^0.10.1
ws: ^6.1.0
optionalDependencies:
art-template: ^4.13.2
compression: ^1.7.4
connect-history-api-fallback: ^1.3.0
csurf: ^5.0.1
debug: ^4.1.1
ejs: ^3.1.6
express-validator: ^6.6.1
fs: ^0.0.1-security
http-proxy: ^1.18.1
i18n: ^0.8.4
morgan: ^1.9.1
method-override: ^3.0.0
multiparty: ^4.2.2
nodemailer: ^6.7.3
passport: ^0.4.1
path-to-regexp: ^1.7.0
serve-favicon: ^2.5.0
session: ^1.15.6
serve-index: ^1.9.1
swig: ^1.4.3
swagger-ui-express: ^4.1.0
ws: ^6.1.0
devDependencies:
@types/body-parser: ^1.19.0
@types/cookie-parser: ^1.4.4
@types/compress: ^1.7.4
@types/connect: ^3.7.0
@types/cookie-session: ^1.4.0
@types/debug: ^4.1.1
@types/dot-prop: ^5.2.0
@types/engage: ^1.0.0
@types/encodeurl: ^1.0.1
@types/escape-html: ^1.0.5
@types/express-serve-static-core: ^4.0.2
@types/express-session: ^1.15.6
@types/finalhandler: ^1.4.3
@types/formidable: ^1.2.2
@types/fs: ^0.0.1-security
@types/http: ^0.0.0-security
@types/http-errors: ^1.6.3
@types/mime: ^1.3.4
@types/ms: ^2.1.3
@types/negotiate: ^1.0.0
@types/parseurl: ^1.5.0
@types/path-to-regexp: ^1.7.0
@types/promise: ^8.0.0
@types/range-parser: ^1.2.0
@types/send: ^0.17.1
@types/serve-static: ^1.13.1
@types/type-is: ^1.6.16
@types/util-deprecate: ^1.0.2
@types/vary: ^1.1.0
@types/view: ^1.1.4
@types/vm: ^0.10.1
@types/ws: ^6.1.0
@types/art-template: ^4.13.2
@types/compression: ^1.7.4
@types/connect-history-api-fallback: ^1.3.0
@types/csurf: ^5.0.1
@types/debug: ^4.1.1
@types/ejs: ^3.1.6
@types/express-validator: ^6.6.1
@types/fs: ^0.0.1-security
@types/http-proxy: ^1.18.1
@types/i18n: ^0.8.4
@types/morgan: ^1.9.1
@types/method-override: ^3.0.0
@types/multiparty: ^4.2.2
@types/nodemailer: ^6.7.3
@types/passport: ^0.4.1
@types/path-to-regexp: ^1.7.0
@types/serve-favicon: ^2.5.0
@types/session: ^1.15.6
@types/serve-index: ^1.9.1
@types/swig: ^1.4.3
@types/swagger-ui-express: ^4.1.0
@types/ws: ^6.1.0
@types/yargs: ^14.0.0
art-template: ^4.13.2
compression: ^1.7.4
connect-history-api-fallback: ^1.3.0
csurf: ^5.0.1
debug: ^4.1.1
ejs: ^3.1.6
express-validator: ^6.6.1
fs: ^0.0.1-security
http-proxy: ^1.18.1
i18n: ^0.8.4
morgan: ^1.9.1
method-override: ^3.0.0
multiparty: ^4.2.2
nodemailer: ^6.7.3
passport: ^0.4.1
swig: ^1.4.3
swagger-ui-express: ^4.1.0
yargs: ^14.0.0
这个输出包含了express包的详细信息,包括它的名称、版本、描述、依赖、可选依赖、开发依赖等。
通过以上方法,你可以在npm i命令安装包时轻松查看已安装包、全局已安装包、特定包的版本信息、已过时的包以及包的详细信息。这些方法可以帮助你更好地管理项目依赖,提高开发效率。
猜你喜欢:全栈链路追踪