Erik Hermansen
Erik Hermansen

Reputation: 2379

How to uninstall an invalid global NPM package?

When I list my globally installed packages, I get output like this:

home$ npm list -g --depth=0
/usr/local/lib
├── [email protected]
├── [email protected]
├── [email protected]
├── @acme/[email protected] -> /Users/me/projects/somelib (acme-somelib) invalid
└── [email protected]

The "somelib" package above is reported as invalid. I'd like to remove the "somelib" package to be sure that it's not contributing to some other problem, and generally, just to keep things clean. But the uninstall command fails for me:

home$ npm uninstall -g @acme/somelib
npm WARN uninstall not installed in /usr/local/lib/node_modules: "@acme/somelib"

I tried also to reinstall ( npm install -g @acme/somelib ) and then do an uninstall. In this case, the install creates a new and separate package that doesn't influence the invalid package. So that doesn't do anything to fix the problem.

How do I get rid of the invalid package?

Upvotes: 1

Views: 385

Answers (1)

Erik Hermansen
Erik Hermansen

Reputation: 2379

Delete the package directory from the command line. E.g. rm -rf /usr/local/lib/@acme/[email protected].

Restated comment answer from @FelixKling for the sake of following the Q&A pattern. Thanks, Felix.

Upvotes: 1

Related Questions