Search code examples
node.jsnpmstylelint

How do I uninstall a folder of node modules that's been installed in the wrong directory (Mac)?


I have accidentally installed 409 node modules in a project directory, while trying to install the 'stylelint' module.

I'm unfamiliar with this and thought it was going into a 'global' place (wherever that is) but instead it's installed it and 408 other modules into a "node_modules" folder, along with "package-lock.json" in a low level project directory.

I did this by running the following command in the random project directory by mistake: sudo npm install stylelint --save-dev

And then in an attempt to remove it: `sudo npm uninstall stylelint'

It says it has removed 1 package of the 409. It also gave a bunch of warnings each time about missing descriptions/readmes.

I just want to completely undo what I did - uninstall all these modules, remove all the new files etc. Please could someone help?


Solution

  • You could just remove the npm_modules directory:

    $ rm -rf my_project/npm_modules