npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm-install with git url will install default branch instead of `master` branch

What I Wanted to Do

Hi,
I found a bug in CLI or a error in documentation.

I would install package with git url repository instead semver.
Like describe the documentation I expect to get the master branch.

What Happened Instead

Instead we got the default branch of repository.

Reproduction Steps

To reproduce I create a minimal project https://github.com/zckrs/bug-npm-cli with two branch:

You can reproduce with a minimal package.json

{
  "name": "test-git-url",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "bug-npm-cli": "zckrs/bug-npm-cli"
  },
  "license": "ISC"
}

Details

I check with some version of npm:

I see nothing in changelog (https://github.com/npm/npm/releases/tag/v5.6.0)

Platform Info

$ npm --versions
{ 'test-git-url': '1.0.0',
  npm: '6.4.1',
  ares: '1.10.1-DEV',
  cldr: '32.0',
  http_parser: '2.8.0',
  icu: '60.1',
  modules: '57',
  napi: '3',
  nghttp2: '1.32.0',
  node: '8.11.3',
  openssl: '1.0.2o',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.19.1',
  v8: '6.2.414.54',
  zlib: '1.2.11' }
$ node -p process.platform
linux


This is intentional, and I consider the master-focused version to have been a bug. Your PR (https://github.com/npm/cli/pull/64) should get things documented properly. Thanks!