无需安装 npm 即可下载 npm dist 包 [英] Download npm dist package without having to install npm

查看:94
本文介绍了无需安装 npm 即可下载 npm dist 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以下载 npm 包而无需执行 npm view XXX ... 或者基本上不需要安装 node/npm?我正在尝试在 linux 机器上执行此操作.

Is there a way I can download an npm package without having to do a npm view XXX ... or basically just not having to install node/npm? I'm trying to do this on a linux machine.

~编辑~我意识到我应该对我在这里尝试实现的目标进行一些说明:我所需要的只是具有依赖项的包文件,这些文件将作为 cloudfront 上的静态资源.我希望 npm 提供一种像 maven-central 那样直接下载人工制品的方法.

~EDIT~ I realize I should've added some clarification on what I'm trying to achieve here: all I need are the package's files with dependencies to be served as a static resource on cloudfront. I'm hoping npm provides a way to directly download the artefact like the way maven-central does.

推荐答案

您可以使用 NPM api 访问原始包.

You can access to the raw package using the NPM api.

http://registry.npmjs.org/{package-name}/{version}

上面的 url 将为您提供包含包元数据的 JSON 响应.包属性 dist.tarball 包含可以下载包的 url.

The url above will give you a JSON response containing the package metadata. The package property dist.tarball contains an url where the package can be downloaded.

请记住,您必须自己安装软件包的依赖项

Keep in mind you have to install the dependencies of the package on your own

示例:

http://registry.npmjs.org/lodash/4.17.10

NPM API 文档

这篇关于无需安装 npm 即可下载 npm dist 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆