Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download npm dist package without having to install npm

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.

like image 578
ravenblizzard Avatar asked Jun 19 '18 17:06

ravenblizzard


1 Answers

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

like image 124
lleon Avatar answered Sep 19 '22 22:09

lleon