npm view
查询 package 的详细信息
可以通过npm view \<package-name>命令查询包名是否已存在,如果存在就会返回该包的相关信息。
比如查询vue这个包名,会返回它的版本号、许可证、描述等信息
npm view vue
vue@3.2.33 | MIT | deps: 5 | versions: 372
The progressive JavaScript framework for building modern web UI.
https://github.com/vuejs/core/tree/main/packages/vue#readme
keywords: vue
# 后面太多信息这里就省略...
如果查询一个不存在的包名,则会返回 404 信息
npm view vue123456
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/vue123456 - Not found
npm ERR! 404
npm ERR! 404 'vue123456@latest' is not in this registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
# 后面太多信息这里就省略...
查询某 package 的可选安装版本
例如,通过命令行查询 @vue/cli 可选的安装版本:
npm view @vue/cli versions --json

浙公网安备 33010602011771号