admin管理员组

文章数量:1178539

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.

~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.

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.

~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.

Share Improve this question edited Jun 19, 2018 at 17:42 ravenblizzard asked Jun 19, 2018 at 17:07 ravenblizzardravenblizzard 3861 gold badge3 silver badges12 bronze badges 3
  • 1 Yes, you can do that. No, you should not do that. What's the constraint that you can't install npm? – Jared Smith Commented Jun 19, 2018 at 17:20
  • 1 Most npm packages are hosted on github - just visit the corresponding repositorsy and download the zip. – connexo Commented Jun 19, 2018 at 17:26
  • @connexo They don't have a release artefact on their GitHub page. All I'm trying to do is to fetch sources (with dependencies) and serve as a static resource on cloudfront. I was just hoping npm provides a way to directly download the artefact like the way maven does. – ravenblizzard Commented Jun 19, 2018 at 17:31
Add a comment  | 

2 Answers 2

Reset to default 42

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

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

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

Example:

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


NPM API documentation

Download lib folder from github.com-get all files within it

Put all the files next to your node application in the same folder. at the top of your file append it like sooo....

var "" = require("./""")

本文标签: javascriptDownload npm dist package without having to install npmStack Overflow