Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download source from npm without installing it

How can I download the source code of a package from npm without actually installing it (i.e. without using npm install thepackage)?

like image 436
AURIGADL Avatar asked Feb 23 '13 01:02

AURIGADL


People also ask

How do I download npm offline?

You simply copy the package and all dependencies in your node_modules folder, inside the project for local installation, or in the global folder ( npm config get prefix to see where it is located) for a global installation. The behavior of npm install is to check for the dependencies, and install them first.

Can I run npm build without npm install?

npm install installs dependencies into the node_modules/ directory, for the node project you're working on. You can call install on another node. js project (module), to install it as a dependency for your project. npm run build does nothing unless you specify what "build" does in your package.

Where can I download npm packages?

Download an NPM package Download the package tarball directly from the public NPM registry using the npm pack command.


2 Answers

You can use npm view [package name] dist.tarball which will return the URL of the compressed package file.

Here's an example using wget to download the tarball:

wget $(npm view lodash dist.tarball) 
like image 139
Gustavo Rodrigues Avatar answered Sep 23 '22 08:09

Gustavo Rodrigues


A simpler way to do this is npm pack <package_name>. This will retrieve the tarball from the registry, place it in your npm cache, and put a copy in the current working directory. See https://docs.npmjs.com/cli/pack

like image 27
grahamaj Avatar answered Sep 24 '22 08:09

grahamaj