2

If I run npm ls at the top level of my project, I get a number of extraneous errors. I tried running npm prune but when I run npm ls again the packages are still there.

How do I remove those extraneous packages?

I have package-lock file and I'm running npm 6.4.1.

1
  • Just a note for others arriving from search engines: npm prune is the command you're looking for and it should remove extra packages (and did in my case). Commented Jun 7, 2023 at 20:35

1 Answer 1

1

First, did you do a npm i to be sure to install all the packages? You can also delete your node_modules folder and your package-lock.json file to have a clean install.

Then if you want to remove packages, you need to npm uninstall them or manually remove them from your package.json file, then re-do a npm i.

Sign up to request clarification or add additional context in comments.

4 Comments

I did run npm install initially. I also deleted the node_modules directory but not the package-lock.json file. Wouldn't prune update packages.json and package-lock.json?
@ventsyv so does it work if you manually delete package-lock.json and manually remove the unwanted modules from package.json ? I'm not quite sure about npm prune
That did it but now when I run npm ls a get a large number of missing packets and 102 vulnerabilities?
can you post your package.json?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.