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

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

Related

No valid versions available for undefined when running npm install -g #angular/cli

Running Windows 10 Enterprise.
I am trying to install angular cli to run the angular project. I entered below command.
--> npm install -g #angular/cli
I m getting below error.
--> npm ERR! code ENOVERSIONS
--> npm ERR! No valid versions available for undefined
what am i doing wrong
Seems to be you have to uninstall the node version and have to install it again
In order to run the npm install -g #angular/cli You need to have the node installed. Please find the below link to install the relevent node version for your PC. And try running the npm install -g #angular/cli command again.
Download the Node.js
Please make sure old node_modules are completely deleted and package-lock.json . Try fresh npm install now
rm package-lock.json
rm -rf node_modules
npm install

Why does the newest Angular CLI have a corrupted packages?

I installed the latest Node and Angular on Windows 10
npm install npm#latest -g
npm install -g #angular/cli#latest
But when I try to start a project ng new new-project I get the following error
npm WARN tarball tarball data for #angular/compiler#^6.1.0 (sha512-TY6axB1c7VvYXf+ebFDq3Ej+edgii3CDxew8HnyTFAWeDF2Gh8io1vTYwtdyDka6U53ASaheM1HpiUjzvYH0jQ==) seems to be corrupted. Trying one more time.
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\admin\Desktop\...\node_modules\.staging\#angular\common-6be83a81\locales\si.js'
...
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\admin\AppData\Roaming\npm-cache\_logs\2018-10-08T01_01_48_404Z-debug.log
Package install failed, see above.
I tried to uninstall Node.js and Angular CLI completely and then reinstall again
npm install npm#latest -g
npm install -g #angular/cli#latest
But still the same error ..... So I googled this issue. It seems like some people had it too, but then it magically disappeared for some people.
How to fix this?
I was getting the same below error when attempting to a create new project using ng new command.
npm WARN tarball tarball data for #angular/compiler#~7.2.0
(sha512-5yb4NcLk8GuXkYf7Dcor4XkGueYp4dgihzDmMjYDUrV0NPhubKlr+SwGtLOtzgRBWJ1I2bO0S3zwa0q0OgIPOw==)
seems to be corrupted. Trying one more time.
I tried many things but what did not worked and what finally worked for me I have listed below. My working node version is 12.2.0 and npm version is 6.9.0 (i.e. latest version).
What did not worked:
Downgraded node js to other lower versions (tried many version)
Deleted package-lock.json file from project and executed npm install
Executed npm install --registry https://registry.cnpmjs.org instead of npm install
Deleted npm and npm-cache folders from AppData\Roaming and then again installed node js
Deleted node_modules folder, executed npm update and then executed npm install
Executed npm cache clean --force and then executed npm install
Reinstalled #angular/cli
Checked for any firewall / antivirus (in my case it was disabled)
Opened node command prompt as an administrator
Checked user permissions for the project folder
Finally what worked is:
Installed the component for which it was giving error. npm install -global #angular/compiler
I had the same problem with node 12.13.0 and npm 6.13.0
npm WARN tarball tarball data for #angular/compiler#^7.2.11 (sha512-5yb4NcLk8GuXkYf7Dcor4XkGueYp4dgihzDmMjYDUrV0NPhubKlr+SwGtLOtzgRBWJ1I2bO0S3zwa0q0OgIPOw==) seems to be corrupted. Trying one more time.
For me the problem was npm. After upgrading npm to the newest version with npm i -g npm#latest the problem vanished. So it seems to be a problem with npm itself and not the Angular/CLI.
upgrade your NPM version use this command i -g npm#latest it works like magic

npm WARN npm npm does not support Node.js v9.1.0

I updated to the latest node v9.1.0 and now npm doesn't work.
npm WARN npm npm does not support Node.js v9.1.0
It turns out that the current installed npm is not compatible with the new node and has a hard time updating.
The solution is to uninstall npm and then reinstall node which will contain the correct version of npm.
Here's how:
Uninstall npm.
Mac:
sudo npm uninstall -g npm
Windows:
npm uninstall -g npm
Install node from https://nodejs.org
Uninstall the global instance of npm:
npm uninstall -g npm
This will cause your system to fall back on the version of npm installed by node 9.1.0 and the warning will disappear.
What worked for me was to delete npm and npm cache from C:\Users\chrisd\AppData\Roaming
Then I ran npm i -g npm#next for the latest version of npm for Node 9.x
NPMJS.org has issued a new release 11.27.2017 -- npm v5.6.0
(You may not have to delete the npm/npm cacheif you just upgrade, but I had already done that before finding the new release)
NPMJS Release notes
Fixed my issue update to 5.71
npm uninstall -g npm
npm i -g npm#next
Had similar issue in linux/ubuntu, below helped solving it.
Remove existing versions of npm and node:
sudo apt --auto-remove purge npm
sudo apt --auto-remove purge nodejs
Re-install node
for me worked
npm uninstall -g npm
npm i -g npm#next
No need for manual installation or clearing the cache.
Run with admin credentials if needed.
I saw this warning after I upgraded to Node 10.4.1 after that I just ran npm uninstall -g npm with -g flag to remove it globally and the error was gone. I guess it updated my npm to version 6.1.0
Solution :
Go to the path where you can find the debug log (this file is found in your npm-cache folder) C:\Users\yourname\AppData\Roaming
Delete the NPM and NPM-Cache folder, but DO NOT reinstall node. Once deleted go back to your command line and re-use the command " npm install -g npm#latest "
What worked for me - On Ubuntu
Install nodejs
sudo apt install nodejs
Install npm
curl -L https://www.npmjs.com/install.sh | sudo sh
If you are unable to uninstall npm, instead you can skip that step and just
Reinstall npm https://nodejs.org/en/
This error occurs when the npm version not compatible with the node version. However npm uninstall -g npm also gives the same error for me.
So following steps work for me.
Option 1:
Step1: Follow this directory
C:\Users(your username)\AppData\Roaming
Step2: Delete the npm folder. And if there is a folder called `npm cache, delete it also.
Step3: Run npm clean cache —force ( — force is now required to clean cache)
If the above option is not worked for you please follow the below steps.
Option 2:
Follow this directory
C:\Users(your username)\AppData\Roaming
Delete the npm folder and if there is one mom cache folder.
Run npm clean cache --force ( -- force is now required to clean cache)
Make sure everything to do with Nodejs is deleted and uninstalled.
Reinstall Nodejs.
I had the same issue with npm when I have updated Node js on windows. I tried many things but only working solution was :
First uninstall npm with below command
npm uninstall -g npm
Now Install latest version
npm install npm#latest -g
If you are using Mac and brew, that's how I've got rid of this problem:
Even though I installed and reinstalled node with brew, with last version 11.8.0, apparently it kept using the last version
fdecollibus$ npm install --global gatsby-cli
npm WARN npm npm does not support Node.js v11.8.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
/usr/local/Cellar/node/11.8.0/bin/gatsby -> /usr/local/Cellar/node/11.8.0/lib/node_modules/gatsby-cli/lib/index.js
+ gatsby-cli#2.4.8
npm -v gave me back version 5.6.0. I've therefore noticed that /usr/local/lib/node_modules had wrong permissions assigned to root:wheel.
A chown did not fix the problem: I've had to manually delete the content of the folder (cd /usr/local/lib/node_modules and -careful - type rm -rf * ) to get rid of the folder.
Then I've run brew uninstall node and again brew install node, and finally npm -v gave me back 6.5.0
Executing npm uninstall -g npm gave me same error
Uninstall Node.js installed in the system
Goto c:\Program File\nodejs (default location of the nodejs installation). Remove all contents of the folder manually.
Remove npm, npm-cache folder from Roaming folder under your username.
Install Node.js again.
running npm install #angular/cli -g worked for me.
I was getting the below warning when I executed, npm install to install package.json for my angular project.
npm WARN npm npm does not support Node.js v9.1.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
WARNING: You are likely using a version of node-tar or npm that is incompatible with this version of Node.js.ng-080b84bf08dd68e5.lock for ...\Angular\node
Please use either the version of npm that is bundled with Node.js, or a version of npm (> 5.5.1 or < 5.4.0) or node-tar (> 4.0.1) that is compatible with Node.js 9 and above.
C:\Program Files\nodejs\node.exe: src\node_zlib.cc:437: Assertion `args.Length() == 7 && "init(windowBits, level, memLevel, strategy, writeResult, writeCallback," " dictionary)"' failed.
According to #Ilyich, I uninstalled global npm, npm uninstall -g npm
And then I executed npm install to install my package, it installed successfully.
Navigate to the Appdata by typing %AppData% in the run or search.
Delete the npm and npm-cache folder and then install the nodejs again. It solved the issue for me.
If you are getting the same warnings while creating or importing an Angular project in an IDE such as Eclipse ,do the following:
File->New->Angular
In the window that appears change the versions of Nodejs and NPM to "use system installation"
...
If the process crashes at "installing packages for tooling via npm"
Close the terminal in IDE and manually go to the project directory and do "npm install".
Refresh the project in IDE
I had a similar issue trying to install other stuffs.
And looks like the npm version was not compatible with my node version.
In my case i had npm 5.4.2 and node v10.15.0
At the end of this process i had the version npm 6.7.0 and node v10.5.0
First Option:
I downgrade the version of node and other tools.
On terminal execute the next command with the version to be installed. (Example if we need change to node 8.14.1)
1.- Npm install -g node#8.14.1
Then we execute the command to uninstall the version to be removed.
2.- Npm uninstall -g node#8.15.0
After that we need execute the next command to set the new path
3.- Npm update -g node#8.14.1
Finally we only need execute the version to see if the changes were added successfully
4.- Node -v
In this case we will see the version as 8.14.1 and we finished the process.
If you want do it for Appium and Npm version you can open a new terminal and follow the same steps in order to change the version. For example:
Npm install -g appium#1.7.2
Npm uninstall -g appium#1.10.0
Npm update -g appium#1.7.2
Appium -v
In my case you must have the next versions:
Node 8.14.1
Npm 6.4.1
Other Way:
To solve it i just execute in the terminal the next line.
curl -L https://npmjs.org/install.sh | sh
After download a few files (took around of 10 minutes to see results in the terminal) i was able to continue working with the new latest and compatible version of both tools.
The next WARM was displayed in this case.
npm WARN npm npm does not support Node.js v10.15.0.
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
/Users
I am on a macOS and what ended up working for me was uninstalling npm, relinking Node, and reinstalling Node through Homebrew. (Prereqs: Have Homebrew installed and have a very confusing setup where npm and Node don't work together)
1. To uninstall homebrew:
If you are on a Mac, you probably don't see the AppData\Roamingfolder; you should instead go to npm root -g and delete the npm_modules folder. Now, when you type npm --version your computer should be confused.
2. Reinstalling node:
Try doing brew install node and if you already have node installed, your computer will ask you to reinstall it. If you do brew reinstall node and your versions of brew and npm look good, then you don't need to do the last step!
3. If you need to link the correct version of Node:
This step was something I think was my fault since I think I had installed Node through Homebrew as well as the actual online download. Follow the suggestions after brew link node which should take you to brew link --overwrite node. There will be around 7 directories that the command will not be able to overwrite, which you should all delete using sudo rm -rf directory_name. (Do use your common sense, don't delete something important.) After you are finally able to run the brew link --overwrite node command without any errors, you should then do brew reinstall node since you don't have npm anymore.
Tada! You hopefully now have version of npm and node that hopefully can work together.
Just install latest version of Node.js from https://nodejs.org
This will automatically update npm for you
Easiest way I found was to install the latest node with brew and the latest npm manually:
brew uninstall node
brew install node
npm install -g npm#latest
This removed the warning message. For some reason brew wasn't linking the new npm installed by node while it was updating node itself.
The easiest way(for windows) is to use the installer to remove node, then use it to reinstall node, at which time it will install the correct version of npm. running the above uninstall commands does not work, since the wrong version of node is installed, otherwise you wouldn't have this issue.
You can uninstall node current version, and install a early version that support npm. Then run npm install npm#latest -g and install current node version.
It's work for me
lowering the npm version worked for me (windows 10):
npm i npm#6.14.11
To upgrade the npm and Node:
Step 1. Uninstall the npm:
Mac: `sudo npm uninstall -g npm`
Windows: `npm uninstall -g npm`
Step 2: Install the latest version of Node: https://nodejs.org/en/

Unable to npm install or start with electron-quick-start

I am using the version of node that is stated on electron's site, which is 7.4.0 and I'm using NPM version 4.0.5 (Windows).
The problem I'm having is with the npm install command in the cloned electron-quick-start folder. I have tried using the command with --save-devand -g but they don't do anything to help.
Upon using just npm install;
fetchMetadeta: still install loadAllDepsIntoIdealTree
With the above stated arguments (output);
--electron-quick-start#1.0.0
Then npm start after the above output;
Pastebin
Any help would be greatly appreciated, thanks.
You must get npm install to work before you can start the app
You could try the following
npm cache clean
npm install This will cache clean of npm
npm install -g yarn
yarn install This will install yarn (This will probably work but it might not be what you're looking for). Yarn is an alternative to npm
npm -g install npm
npm install This will reinstall npm
And I would look into nvm and nvm-windows
And if none of those work I would look at
this issuse on github
And if that doesn't work I would just look at google

With NodeJS, How To execute a series of node installs

I've got a file (like below) that has a list of npm install commands. I was hoping I could do
npm < files.txt
to get it to run those but that does not work. How can I install all these packages? I hate to put them all on one big line.
npm install angular angular-ui-router --save
npm install angular watchify browser-sync --save
npm install angular-mocks --save
npm install angular-sanitize --save
....

Resources