0

Rather than typing npm run lint I accidentally wrote npm un lint. I understand that un is a synonym for uninstall, but no package lint ever existed in our package.json.

The command line says it's added 5 packages and removed 13. The package.json hasn't changed though, and as far as I can tell neither has package-lock.json.

Running 'npm list | grep lint' only shows eslint, and lint-staged, both of which I believe are still installed.

Running npm i doesn't install anything new.

How do I find out what happened, and what packages were added/removed?

reymon359
  • 1,240
  • 2
  • 11
  • 34
AncientSwordRage
  • 7,086
  • 19
  • 90
  • 173
  • It's an alias for https://docs.npmjs.com/cli/uninstall - you should be able to see what's changed if you diff the `package-lock.json`. – jonrsharpe Jul 16 '20 at 09:42
  • @jonrsharpe I'm aware of that, but I don't have that package installed. The package-lock.json file is in our git repo, and it's not showing as changed in vscode. I can dig further though. – AncientSwordRage Jul 16 '20 at 09:54
  • Was [`lint`](https://www.npmjs.com/package/lint) a dependency of some other package - it has 31 dependents listed? Or are you certain that it _"doesn't exist in your project"_? Perhaps adding your _package.json_ to your question may increase your chances of getting an answer. – RobC Jul 16 '20 at 10:36
  • @RobC I am not on the same network at the package.json, but there's nothing there I can see from that dependents list. – AncientSwordRage Jul 16 '20 at 10:38
  • That _dependents list_ doesn't conclude that it wasn't in your complete dependency tree though. – RobC Jul 16 '20 at 10:47
  • @RobC I've checked my dependency list for 'lint', it's not in there. The question in the title still stands though – AncientSwordRage Jul 16 '20 at 11:14
  • @Pureferret - and you checked that when, _before_ or _after_ running `npm un lint`? – RobC Jul 16 '20 at 11:17
  • @RobC after, but wouldn't that show what each package.json lists as it requiring, not what is currently installed? Also, if it was required, wouldn't me running 'npm install' have re-added it? – AncientSwordRage Jul 16 '20 at 11:21
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/217959/discussion-between-robc-and-pureferret). – RobC Jul 16 '20 at 11:37

1 Answers1

1

there are 2 scopes, namely global and local. usually, the execution of npm turns to the local and then turn to the global.

in your case, the npm un did not follow any local scope options, such as --save, so you probably operated on the global scope.

that is why you do not see any changes to the package-lock.json

Mr.
  • 9,429
  • 13
  • 58
  • 82
  • [npm un](https://docs.npmjs.com/cli/uninstall) requires the `[--global|-g]` option to uninstall a package from the context of the global scope. So what makes you think that they _"probably operated on the global scope."_? – RobC Jul 16 '20 at 12:22