Git Product home page Git Product logo

download-npm-package's Introduction

download-npm-package

Download a module from the npm registry.

Installation

npm [-g] install download-npm-package

Features

  • Library to download packages
  • CLI to download packages
  • Will use registry (and auth) defined in your .npmrc file
  • Supports scoped packages

Usage

node

downloadNpmPackage takes an package arg & a path as arguments and returns a promise, a promise that resolves once the package has been downloaded to the folder set in path.

import downloadNpmPackage from 'download-npm-package';

downloadNpmPackage({
  arg: 'modulname@version' // for example, npm@2 or @mic/version@latest etc
  dir: '/tmp' // package will be downlodaded to ${dir}/packageName
}).then()

cli

There's also a cli available!

download-npm-package $packageArg [$path]

download-npm-package's People

Contributors

kesla avatar greenkeeperio-bot avatar egoist avatar

Stargazers

Roman avatar Goze avatar Lê Trần Duy Tân avatar Sven avatar  avatar Slava Fomin II avatar 沈鸿飞 avatar anyinfa avatar  avatar 忽如寄 avatar Ilya Zolotov avatar ZHAO Xudong avatar Oliver Salzburg avatar Huang ShuWei avatar cinwell.li avatar Jerry.jiao avatar tensuns avatar mandarin avatar Stefan Cameron avatar Sergey Kopylov avatar Chris Watson avatar Ivan Babak avatar Shubham Kanodia avatar  avatar

Watchers

James Cloos avatar

download-npm-package's Issues

package description and example are wrong/outdated

NPM package description gives this usage example
`
import downloadNpmPackage from 'download-npm-package';

downloadNpmPackage({
arg: 'modulname@version' // for example, npm@2 or @mic/version@latest etc
path: '/tmp' // package will be downlodaded to ${path}/packageName
}).then()
`

There is no "path" option. It's called "dir" in the source code. Current example fails to process the package. It works okay when path is replaced with dir.

Protocol "https:" not supported. Expected "http:"

I tried to download antd package via download-npm-package antd, but it gave you the following error.

C:\Users\Liu.D.H>download-npm-package antd
_http_client.js:151
    throw new ERR_INVALID_PROTOCOL(protocol, expectedProtocol);
    ^

TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"
    at new ClientRequest (_http_client.js:151:11)
    at Object.request (https.js:308:10)
    at get (C:\Users\Liu.D.H\AppData\Roaming\npm\node_modules\download-npm-package\node_modules\got\index.js:33:18)         at ClientRequest.<anonymous> (C:\Users\Liu.D.H\AppData\Roaming\npm\node_modules\download-npm-package\node_modules\got\index.js:51:5)
    at Object.onceWrapper (events.js:309:26)
    at ClientRequest.emit (events.js:219:5)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:598:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:113:17)
    at Socket.socketOnData (_http_client.js:467:22)
    at Socket.emit (events.js:219:5) {
  code: 'ERR_INVALID_PROTOCOL'
}

C:\Users\Liu.D.H>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.