How can I uninstall npm version [duplicate] - node.js

This question already has answers here:
Message "npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead"
(23 answers)
Closed 3 months ago.
My npm version is 8.11.0.
When I create react package, but it gives me a Warn.
How can I uninstall it?

npm uninstall <package_name>
To uninstall an unscoped, global package on the command line, use the uninstall command with the -g flag:
npm uninstall -g <package_name>

Locally uninstall npm package:
To uninstall a package you have previously installed locally, run following from the project root folder (the folder that contains the node_modules folder):
npm uninstall <package-name>
Note: This operation will also remove the reference in the package.json file.
If the package was a development dependency, listed in the devDependencies of the package.json file, you must use the -D / --save-dev flag to remove it from the file:
npm uninstall -D <package-name>
Globally uninstall npm package:
If the package is installed globally, you need to add the -g / --global flag:
npm uninstall -g <package-name>

You need to just write in your terminal
npm uninstall <package_name_which_you_want_to_uninstall>

Related

how to uninstall a package that was installed with --save keyword

I'm working on a react js project with this spec:
node -v --> v16.15.1
npm -v --> 8.11.0
I usually install packages with npm install package-name --legacy-peer-deps and uninstall it with npm uninstall package-name --legacy-peer-deps which usually works fine.. but in one of the recent package I installed, I copied the command from the website and I remember there was --save keyword in it. now I want to uninstall it since I don't use it anymore so I ran this commands:
npm uninstall package-name --legacy-peer-deps
npm uninstall package-name --save --legacy-peer-deps
but the package name is still in the package.json file. what should I do to completely remove the package from my react js appliation?
remove it from your package.json and run npm install

Your global Angular CLI version (6.0.8) is greater than your local version (1.0.2)

C:\dev\myApp> ng serve -o
Your global Angular CLI version (6.0.8) is greater than your local version (1.0.2).
The local Angular CLI version is used.
To disable this warning use `"ng config -g cli.warnings.versionMismatch false"`
I don't know what to do with this.
I tried uninstalling angular/cli and npm cache clean but still have problems.
Anyone help me !
You have the old angular/cli package in your package.json
To update use:
npm r angular-cli
npm i #angular/cli#latest -D
Be aware though, if you have already been using the old cli for a long time, you might have to do some code migration. Especially when it comes to tests, polyfills and the angular config file.
You could try to create an empty angular project using the new cli, and compare the files which are created there, with the files you have in your own project, and update where applicable.
After that, when you have to update your cli again, you can use the new ng update command
You are using new project in older CLI you need to run this commands
npm uninstall --save-dev angular-cli
npm install --save-dev #angular/cli#latest
npm install
or you can try this approach
Updating npm :
Run [sudo] npm install -g npm (sudo is only required on Mac/ Linux)
Updating the CLI :
[sudo] npm uninstall -g angular-cli #angular/cli
npm cache clean
[sudo] npm install -g #angular/cli
i have try all command above but, it don't work. Maybe you can try this command for same probblem. it work for me.
ng update #angular/cli #angular/core
npm uninstall --save-dev angular-cli
npm install
if it still problem you can visit : https://angular.io/cli/update
and you can choice "Angular Update Guide" for specify version update from X to X

Difference betweeen npm install and npm install --save? [duplicate]

This question already has answers here:
Difference between npm install --save and npm install --save-dev
(3 answers)
What is the --save option for npm install?
(14 answers)
Closed 5 years ago.
Including of the word --save means? or What is the Difference betweeen:
npm install and npm install --save?
Base on the npm documentations:
For older versions of NPM:
The npm install <package_name> command just downloads the specified package from NPM cloud, and saves it in node_modules directory in your current directory.
The npm install <package_name> --save command downloads the specified package from NPM cloud, and saves it in node_modules directory in your current directory, and also it adds the installed package into dependencies section of your package.json file.
For NPM versions > 5, there is no difference between these two commands. That is, the first command without --save option downloads the package and adds it into dependencies section of package.json file.

How to uninstall global package with npm?

I have installed webpack in this way:
npm install -g webpack
Now want to uninstall it:
npm uninstall -g webpack
Check it again, it didn't been uninstalled:
webpack -v
3.1.0
Why?
And, I use this way can't find webpack:
npm list -g | grep webpack
This also didn't work:
npm uninstall -g webpack --save
After run this under a directory which included package.json:
npm uninstall webpack
npm WARN babel-loader#6.4.1 requires a peer of webpack#1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none was installed.
npm WARN uglifyjs-webpack-plugin#0.3.1 requires a peer of uglify-js#^2.8.0 but none was installed.
npm WARN uglifyjs-webpack-plugin#0.3.1 requires a peer of webpack#^1.9 || ^2 || ^2.1.0-beta || ^2.2.0-rc but none was installed.
Try running both of the below commands:
npm uninstall -g webpack
npm uninstall webpack
I think you might be checking/looking at the local version after deleting only the global one.
You have to remove the packages manually installed globally on your os with sudo:
On OsX navigate to this directory
cd /usr/local/lib/node_modules
and
sudo rm -rf <packageName> // sudo rm -rf webpack
npm uninstall -g webpack
Worked for me, try running the command prompt in administrator mode.
You're most likely running a file from another install of npm.
Run which webpack to see where your shell is finding webpack.
Run npm root -g to find the root of the tree it's supposed to be in, being sure you're running the correct npm with npm -v and which npm.
If your webpack bin isn't in the npm root, reset your path to the webpack binary e.g. hash -d webpack in bash, and then go remove the unwanted npm root from your PATH variable. You can now use npm install -g webpack and npm uninstall -g webpack and it should work.
I have tried uninstalling global packages in several ways.
npm uninstall -g <package_name> this didn't work.
I managed to remove the global packages in the following way:
Goto terminal
Run this command npm list -g
Goto the path (C:\Users\user\AppData\Roaming\npm)
Delete all the related files to your package
Goto node_modules find and delete the package
This should work.
YW!
If you are using Node Version Manager (nvm) and you want to remove a global system package you will need to switch to that version. For example:
nvm use system
npm uninstall -g webpack
Try
chown -R "$(whoami)": "$(npm root -g)"
(you may need sudo for it) and then npm uninstall -g again
on windows run as administrator and run the command
npm uninstall -g webpack
on Linux
sudo npm uninstall -g webpack
In Windows, open the cmd with Administrator rights (start -> type cmd -> right-click on icon -> open with adm. rights), then navigate (in cmd type "cd ../../users/your_user_name") to your user folder, then run
npm uninstall -g webpack
or (I don't remember which one worked for me)
npm uninstall webpack
Had the same issue an none of the answer above helped.
My project was in a sub-directory of a larger project, which also had a node_modules folder.
That's why it says, something like "found another version higher in the tree."
Delete that folder, go back to your sub-dir, remove node_modules and package-lock.json, and finally run npm install again.
In archlinux, after running
npm uninstall -g <package_name>
you might have to manually enter /usr/lib/node_modules/ to remove the package's directory. This will prevent conflicts if you try reinstalling that package with a different package manager like pacman.
Building on #karthik006 's answer of deleting directly from the global node_module folder, if you are using nvm, you first need to decide from which version of node you want to delete the global package.
After that, switch to that version of node using nvm use <version>
Then run nvm which current to get the path where the executable for this version of node is saved.
The path will be something like <path to nvm node dir>/<node version>/bin/node
Using this path, cd into <path to nvm node dir>/<node version>/lib/node_modules and then rm -rf the packages that you want to remove.
On ubuntu the package I was on the hunt for was buried in ~/.npm/_npx/<chars>/node_modules/ and in ~/.npm/_npx/<chars>/node_modules/.bin/. I removed the bin and the directory and got the reinstall prompt.
Try This:
npm uninstall -g <package_name>
E.g: npm uninstall -g webpack

How to sync the dependency of package json in npm

In my case,i use npm install moduleName -save to install a module ,but after npm notice that it is install complete,the package.json will not be add dependencies of the module;
Is there any solution to sync from module to dependencies;
Thanks at first
You need npm install moduleName --save (2 '-')
Actually you can use one -s. Here is the quote from the npm documentation:
As of version 2.0.0 you can provide a path to a local directory that
contains a package. Local paths can be saved using npm install -S or
npm install --save, using any of these forms:
So if you wanted to install lodash you could use:
npm install lodash --save
or:
npm install -S lodash

Resources