Running "npm i" in a directory without package.json creates a new package-locks.json

What I Wanted to Do

Wanted to update packages using “npm i” in wrong directory without package.json and would expect npm to only inform me, that there is no package.json file.

What Happened Instead

npm automatically generates a new package-locks.json file that must be remove manually.

npm WARN saveError ENOENT: no such file or directory, open '/Users/doberkofler/MyDev/ljs_app/branches/wip/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.

Reproduction Steps

Just run “npm i” in a directory with no package.json file.

Details

Platform Info

$ npm --versions
{ npm: '6.7.0',
  ares: '1.15.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.34.0',
  node: '10.15.0',
  openssl: '1.1.0j',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.2',
  v8: '6.8.275.32-node.45',
  zlib: '1.2.11' }
$ node -p process.platform
darwin

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