How can I download the source code of a package from npm without actually installing it (i.e. without using npm install thepackage
)?
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.
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.
Download an NPM package Download the package tarball directly from the public NPM registry using the npm pack command.
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)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With