How can I download the source code of a package from npm without actually installing it (i.e. without using npm install thepackage
)?
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- google-drive can't get push notifications
- Failed at the electron@1.8.2 postinstall script
- How to reimport module with ES6 import
- Webpack getting started, import error
相关文章
- node连接远程oracle报错
- How can make folder with Firebase Cloud Functions
- @angular-cli install fails with deprecated request
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
- unable to install packages(“caret”) completely in
- Transactionally writing files in Node.js
- Log to node console or debug during webpack build
If you haven't installed npm, with the current public API, you can also access the information about a package in the npm registry from the URL
https://registry.npmjs.org/<package-name>/
.Then you can navigate the JSON at
versions > (version number) > dist > tarball
to get the URL of the code archive and download it.npm pack XXX
is the quickest to type and it'll download an archive.Alternatively:
this command will also:
package
You can use
npm view [package name] dist.tarball
which will return the URL of the compressed package file.Based on Gustavo Rodrigues's answer, fixes "package" directory in .tgz, adds latest minor version discovery.
Why don't you create an empty directory outside your project, do an npm install there, and get the source from node_modules.
the full module is right there.
You could also go on http://npmjs.org, look for the module there. Most modules will list there repository and you can get the code from there.
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