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


(Mehdy Dara) #1

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:

  • not-master-but-default: the default branch configure by settings of Github
  • master: the initial 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"
}
  • Run npm install
  • Then cat node_modules/bug-npm-cli/index.js
  • And you will see console.log('repo default branch'); instead of console.log('master branch');

Details

I check with some version of npm:

  • > v5.5.1 will install the master branch
  • <= v5.6.0 will install the default branch of repository

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

(Kat Marchรกn) #2

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!


(system) #3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.