Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 282 Vote(s) - 3.47 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I uninstall npm modules in Node.js?

#11

```lang-none
# Log in as root (might be required depending on install)
su -

# List all global packages
npm ls -g --depth=0

# List all local (project) packages
npm ls -p --depth=0

# Remove all global packages
npm ls -g --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs npm -g rm

# Remove all local packges
npm ls -p --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs npm -p rm

# NOTE (optional): to use node with sudo you can add the bins to /usr/bin
# NOTE $PATHTONODEINSTALL is where node is installed (e.g. /usr/local/node)
sudo ln -s $PATHTONODEINSTALL/bin/node /usr/bin/node
sudo ln -s $PATHTONODEINSTALL/bin/npm /usr/bin/npm
```



Reply

#12
For Windows users - if you want to remove all the Node.js modules installed at once:

- Open a PowerShell window
- Go inside the *node_modules* folder (`cd node_modules`)
- Run this command - "npm uninstall (Get-ChildItem).Name"

It will uninstall all the modules.


Reply

#13
To remove packages in folder *node_modules* in bulk, you could also remove them from file *package.json*, save it, and then run `npm prune` in the terminal.

This will remove those packages, which exist in the file system, but are not used/declared in file *package.json*.

P.S.: This is particularly useful on Windows, as you may often encounter problems with being unable to delete some files due to the "exceeded path length limit".

Reply

#14
If you want to uninstall a number of modules, then just run the `npm uninstall`.

Then go to file *package.json* and delete the unwanted module from there, and then just run the command `npm install`. It should fix your problem.

Reply

#15
The `uninstall` option didn't work for me when I tried to use the same command to the one I used in installing (as I was installing with the `@latest` directive)

So for example, I installed a package like this:

npm install @ngtools/webpack@latest

And then I wanted to uninstall it, so I used the same command (including @latest):

npm uninstall @ngtools/webpack@latest

So the above uninstall didn't work. I have to remove the `@latest`, and then it worked well:

npm uninstall @ngtools/webpack

Reply

#16
Sometimes `npm uninstall -g packageName` doesn’t work.

In this case you can delete package manually.

On Mac, go to folder `/usr/local/lib/node_modules` and delete the folder with the package you want. That's it. Check your list of globally installed packages with this command:

```lang-none
npm list -g --depth=0
```

Reply

#17
The simplest solution is:

```lang-none
npm uninstall packageName --save-dev
```

See upper level packages names in the your project:

```lang-none
npm list --depth=0
```

The output will be like:

```lang-none
[email protected] /home/jackkobec/projects/myAppName
├── packageName@packageVersion
├── [email protected]
```

Copy package name and execute npm uninstall command. Example for express package:

npm uninstall express --save-dev


Reply

#18
Update for npm 5:

As of [npm 5.0.0][1], installed/uninstalled modules are added/removed as a dependency by default, so the `--save` option is no longer needed.

Run

npm uninstall <package>

For example:

npm uninstall mongodb

It will remove the module from the *node_modules* folder and also the *package.json* file.

[1]:

[To see links please register here]



Reply

#19
In case you are on Windows, run CMD as administrator and type:

```lang-none
npm -g uninstall <package name>
```
Reply

#20
You can delete a Node.js module manually. For Windows,

1. Go to the `node_modules` directory of your repository.

2. Delete the Node.js module you don't want.

3. Don't forget to remove the reference to the module in your *package.json* file! Your project may still run with the reference, but you may get an error. You also don't want to leave unused references in your *package.json* file that can cause confusion later.


Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through