Package lockfiles differ by OS when using global-style

priority:medium
triaged
cli
help-wanted

(Jake Magill) #1

What I Wanted to Do

Generate a package-lock file on mac and maintain its consistent generation on linux.

What Happened Instead

Linux changes the package lock file slightly, for no apparent reason.

Reproduction Steps

On a mac computer (I’m on version 10.13.6)…

  1. Run export NPM_CONFIG_PACKAGE_LOCK=true && npm install --package-lock-only --global-style babel-cli@^6.11.4
  2. Copy the package-lock file to a linux computer (I’m on Ubuntu 16.04.5)

On the linux computer…

  1. Go to the directory with the package-lock file in it and ensure you’re on the same version of node
  2. Run cp package-lock.json package-lock.json.orig (so we can diff later)
  3. Run the same install command: export NPM_CONFIG_PACKAGE_LOCK=true && npm install --package-lock-only --global-style babel-cli@^6.11.4
  4. To see the difference run diff package-lock.json package-lock.json.orig

My diff looks like:

637a638
> “nan”: “2.11.1”,
1495a1497,1502
> },
> “nan”: {
> “version”: “2.11.1”,
> “resolved”: “http://npm.redfintest.com:1234/nan/-/nan-2.11.1.tgz”,
> “integrity”: “sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==”,
> “optional”: true

I was able to repro on npm versions 5.6.0 and 6.1.0

NOTE: This only happens when I install dependencies by passing them directly to the install command. If I run this install using a package.json that just contains the babel-cli@^6.11.4 dependency, the output is as expected. So that’s a workaround.

Details

Output from the install command on mac:

npm WARN saveError ENOENT: no such file or directory, open ‘/private/tmp/deleteme/package.json’
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open ‘/private/tmp/deleteme/package.json’
npm WARN deleteme No description
npm WARN deleteme No repository field.
npm WARN deleteme No README data
npm WARN deleteme No license field.

+ babel-cli@6.26.0
added 305 packages in 3.014s

Output from the install command on linux:

npm WARN saveError ENOENT: no such file or directory, open ‘/home/jake/temp/package.json’
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/babel-cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
npm WARN enoent ENOENT: no such file or directory, open ‘/home/jake/temp/package.json’
npm WARN temp No description
npm WARN temp No repository field.
npm WARN temp No README data
npm WARN temp No license field.

+ babel-cli@6.26.0
added 303 packages in 2.671s

Platform Info

$ npm --versions
Mac: { npm: '5.6.0',
  ares: '1.10.1-DEV',
  cldr: '31.0.1',
  http_parser: '2.7.0',
  icu: '59.1',
  modules: '57',
  nghttp2: '1.25.0',
  node: '8.9.4',
  openssl: '1.0.2n',
  tz: '2017b',
  unicode: '9.0',
  uv: '1.15.0',
  v8: '6.1.534.50',
  zlib: '1.2.11' }

Linux: { npm: '5.6.0',
  ares: '1.10.1-DEV',
  cldr: '31.0.1',
  http_parser: '2.7.0',
  icu: '59.1',
  modules: '57',
  nghttp2: '1.25.0',
  node: '8.9.1',
  openssl: '1.0.2m',
  tz: '2017b',
  unicode: '9.0',
  uv: '1.15.0',
  v8: '6.1.534.47',
  zlib: '1.2.11' }

$ node -p process.platform
Mac: darwin

Linux: linux