7

I've never had this happen before, but now, when I npm install in the root directory of my app, my package-lock.json updates all the packages with node_modules/. What is causing this?

Here's what I get before running npm i

before running command

Here's what I get after running npm i

after running command

Sefton419
  • 167
  • 1
  • 2
  • 15
  • Did something change recently in `package.json` with `ajv` and `amqp-connection-manager`? – Milan Tenk Jan 20 '21 at 19:18
  • @MilanTenk this happens with ALL my packages - not just these two. It happens when I `npm install` or `npm uninstall` (anything that updates package-lock.json) locally on my machine. When I do so on my company's ec2 instances, it doesn't happen. – Sefton419 Jan 20 '21 at 20:16

2 Answers2

8

What version of npm (and node) are you using?

npm v7 has been released, and it ships with node v15. That introduces some big changes due to the new support for workspaces... which introduces package-lock.json v2.

I'm going to go out on a limb: I suspect you're running npm v7 locally and your EC2 instances are not.

https://github.blog/2020-10-13-presenting-v7-0-0-of-the-npm-cli/

Nicholas Carey
  • 71,308
  • 16
  • 93
  • 135
  • Thank you Nicholas, that was precisely the problem. I was running the newest version of node. I downgraded with `nvm use v15.6.0` and `npm i` no longer prefixes my packages with `node_modules/` – Sefton419 Jan 21 '21 at 19:41
3

I was able to reproduce issue from OP's question on my computer by running

npm install -g npm@7

and then running

npx create-react-app my-app

Inspecting my-app/package-lock.json confirmed changed behaviour.

I then downgraded npm to 6.14.11 using

npm install -g npm

Deleted folder my-app and repeated create-react-app step above. This time, inspecting my-app/package-lock.json confirmed "normal" behaviour.

Roar S.
  • 8,103
  • 1
  • 15
  • 37