Installing a dependency with Bower from URL and specify version

Edmondo1984 picture Edmondo1984 · Oct 13, 2013 · Viewed 111.3k times · Source

I am trying to install a dependency with Bower using a URL. As of Bower documentation:

Bower offers several ways to install packages:

    # Using the dependencies listed in the current directory's bower.json 
    bower install
    # Using a local or remote package 
    bower install <package>
    # Using a specific version of a package 
    bower install <package>#<version>
    # Using a different name and a specific version of a package 
    bower install <name>=<package>#<version> 

Where <package> can be any one of the following:

  • A name that maps to a package registered with Bower, e.g, jquery.
  • A remote Git endpoint, e.g., git://github.com/someone/some-package.git. Can be public or private.
  • A local endpoint, i.e., a folder that's a Git repository.
  • A shorthand endpoint, e.g., someone/some-package (defaults to GitHub).
  • A URL to a file, including zip and tar files. Its contents will be extracted.

However, then it says, that all the types except the URL allow to specify a version.

How do I specify a version for a URL downloaded dependency?

Answer

Sindre Sorhus picture Sindre Sorhus · Oct 13, 2013

Use a git endpoint instead of a package name:

bower install https://github.com/jquery/jquery.git#2.0.3