Problems with npm versions of cordova project - node.js

I'm working on a Cordova Project.
In my project directory, if I type:
node -v I get v6.11.1
npm -v I get 3.10.10
Sometimes, after adding a new plugin to the project (e.g cordova-plugin-statusbar), it happens that when I build the project I get this error:
Discovered plugin "cordova-plugin-statusbar" in config.xml. Adding it to the project
Failed to restore plugin "cordova-plugin-statusbar" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin cordova-plugin-statusbar#^2.2.3 via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
...
...
npm ERR! Darwin 16.7.0
npm ERR! argv "/Users/myuser/.nvm/versions/node/v6.11.1/bin/node" "/Users/myuser/myprojectfolder/node_modules/.bin/npm" "install" "cordova-plugin-statusbar#^2.2.3"
npm ERR! node v6.11.1
npm ERR! npm v2.15.12
npm ERR! code EPEERINVALID
So npm version is different from the above one.
Can the problem of the plugin fetching be linked to this difference in the versions detected?
And why this happens?

EPEERINVALID means that some packages are outdated, you'll have to update global using -g:
npm update -g
Else you could try re-installing cordova and npm:
npm uninstall -g cordova
npm uninstall
npm install
npm install -g cordova
Else if you use nvm as well? because if there's 2 different versions of npm it might be the case that you have to update npm while calling to the nvm.

Related

npm ERR! code EINTEGRITY when npm install

npm ERR! code EINTEGRITY
npm ERR! sha512-KdCC7X8lzuKpwZqEZX4YQF9n7Dy00tPMWjV0p8ktwNjUIN5MOF+RWDzXUBBp/zJZyMreBxFwBfTwel0oCBzwNQ== integrity checksum failed when using sha512: wanted sha512-KdCC7X8lzuKpwZqEZX4YQF9n7Dy00tPMWjV0p8ktwNjUIN5MOF+RWDzXUBBp/zJZyMreBxFwBfTwel0oCBzwNQ== but got sha512-VzAbE9fQ9JnIKrocjcJB2NgMuP3MU2SAGnurTEVL0Ox5/Bz+9s/MSZ4XHfXkh52YeNjCPc5U169VtIV8v/x29Q==. (327680 bytes)
npm ERR! A complete log of this run can be found in:
tried steps:
npm cache clean --force
removed node modules and package-lock and npm install
uninstall the node and and install latest node
uninstall nvm and reinstall the latest
currently using node version: 10.24.0
currently using NVM version: 1.1.9
current problem:
Try to npm install,but it thrown error of npm ERR! code EINTEGRITY.
This issue arise after switch the node version 10.24.0 to 16.17.0
using nvm
expect:
please share the details with cause

my npm commands aren't working, npm is bugging?

C:\Users\jason\OneDrive\Documents\Web-Dev-Projects\pinterest-clone>npm install
npm ERR! Windows_NT 10.0.19042
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\jason\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v14.17.6
npm ERR! npm v3.10.10
npm ERR! cb.apply is not a function
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\jason\OneDrive\Documents\Web-Dev-Projects\pinterest-clone\npm-debug.log
I am getting this really annoying error that doesn't even tell me what's wrong with npm. I tried deleting and installing node.js again and running the command npm install but I would still get the error. I even tried running a command to use the latest version of npm and it still wouldn't work (npm install -g npm-windows-upgrade & npm-windows-upgrade).
It seems like npm is just being very buggy and doesn't want to work. Help please.
Based on this very similar issue, you really shouldn't be using npm 3.x with Node 14.
You might want to uninstall Node, ensure there are no traces of Node or npm on your system, then reinstall Node 14 or 16.
They automatically install newer versions of npm (6 or newer).
Also, the npm-windows-upgrade package you mention hasn't been updated in 3 years. Maybe don't use it?
You are definitely not running the latest version of the tools. NPM is in v7 and Node.js is in v16. Uninstall what you have currently installed, and download the latest version (make sure to choose Current not LTS) to install the latest version. Here is the link
I'd switch to a package manager specifically for managing different versions of Node + NPM side-by-side on your machine, which saves you the hassle of having to have 1 global installation that just "has to work" for all your projects.
Linux has nvm (node version manager). Since you're on Windows, you might want to check out the Windows-"fork": https://github.com/coreybutler/nvm-windows.
It should prevent incompatible versions of node and npm being installed together.

After Upgrading my npm from version 6 to version 7 (node version was 10) I cant install dependencies for some projects

I had node version 10 installed in my system, after upgrading my npm from version 6 to version 7 I couldn't install the dependencies, and I'm getting error so I had to downgrade my node to 6,
(both npm ci and npm i was failing)
And the project I was testing is this:
https://github.com/Giveth/feathers-giveth
the errors were something like this:
npm ERR! code 128
npm ERR! git dep preparation failed
npm ERR! command /Users/username/.nvm/versions/node/v10.23.0/bin/node /Users/username/.nvm/versions/node/v10.23.0/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/Users/username/.npm/_cacache --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm ERR! code 128
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command git clone --mirror -q ssh://git#github.com/gulpjs/gulp.git /Users/renjer/.npm/_cacache/_cacache/tmp/git-clone-dfb83c15/.git
npm ERR! npm ERR! fatal: destination path '/Users/username/.npm/_cacache/_cacache/tmp/git-clone-dfb83c15/.git' already exists and is not an empty directory.
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR! /Users/username/.npm/_cacache/_logs/2021-02-18T16_18_35_855Z-debug.log
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/username/.npm/_logs/2021-02-18T16_20_15_536Z-debug.log
This problem usually happen because if you only upgrade the node version of the system, there are some packages and dependencies that are installed according to that version.
This is a manual process, but you have to install the package according that version.
For example (package.json):
In your node 6 version you have some package:
"xyz":^1.2.3
that package was installed and its dependencies to work with node 6
delete manually that package from your package.json and install it manually like
npm install xyz
Then is possible that you notice an upgrade to the version, something like:
"xyz":^4.5.6
Do that for everyone of your packages and probably your problem disappears. That's the way that I have used to solve that problem.
You can also upgrade all the packages to its lasts version but ... if you have many packages and someone is not working you are not going to know which one is failing, and you are going to check it individually.
Maybe (at the moment of writing this answer) if you are using Node 10, the latest package's version is not going to work either because that version could be fixed to work with Node 16 (the LTS (Long term support) version at the moment of writing this answer).
If you haven't done that yet, I suggest to continually upgrade your system to the some LTS version that isn't deprecated.

How to fix this Error -npm

I tried to install npm and I got the following error.
I already removed npm and reinstall it again, but I again got the following error:
npm ERR! Linux 4.15.0-30-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! vx-leave-system#0.0.1 start: `node ./tools/server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vx-leave-system#0.0.1 start script 'node ./tools/server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the vx-leave-system package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./tools/server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs vx-leave-system
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls vx-leave-system
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/seelan/Documents/vx-leave-system/npm-debug.log
How can I fix this?
On ubuntu 18.04 following steps saved me
To remove the distro-stable version, type the following:
sudo apt remove nodejs
This command will remove the package and retain the configuration files.
sudo apt purge nodejs
As a final step, you can remove any unused packages that were automatically installed with the removed package:
sudo apt autoremove
Refresh your local package index by typing:
sudo apt update
Enable the NodeSource repository by running the following command
(optinal) If you need to install another version, for example 14.x, just change setup_12.x with setup_14.x
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
Once the NodeSource repository is enabled, install Node.js and npm by typing:
sudo apt install nodejs
Verify that the Node.js and npm were successfully installed by printing their versions:
node --version (v12.18.4)
npm --version (6.14.6)
It seems to me that you're running a newer version of Node, but an outdated version of NPM.
You can do either of the following:
Try the latest stable version of NPM:
You can upgrade to the latest version of npm using: npm install -g npm#latest
Uninstall Node form your machine completely, go to their website and install the latest stable Node version. NPM comes with it.
I faced this issue too today and the problem was caused by an upgrade in my node and npm version. Guess my project dependencies were still running on older versions of node and npm
I fixed it by deleting the node_modules folder and run
npm install
I hope this helps
This looks like a permissions issue in your home directory. To reclaim ownership of the .npm directory execute:
sudo chown -R $(whoami) ~/.npm
Check the updates of dependencies
npm outdate
Run the next command to update dependencies
npm update
Remove the path folder directory C:\Users\ACER\AppData\Local**\npm-cache_logs\2021-12-29T13_41_22_984Z-debug-0.log**
and then run this command in your CLI npm install -g npm#latest
this works with you

Unable to upgrade - slimerjs missing...?

I'm running on OSX (El Capitan) with node v5.0.0 and npm v3.3.9. if I attempt an upgrade:
npm upgrade
I get the error below:
npm WARN deprecated lodash#0.9.2: lodash#<2.0.0 is no longer
maintained. Upgrade to lodash#^3.0.0
npm ERR! Darwin 15.2.0
npm ERR! argv "/usr/local/Cellar/node/5.0.0/bin/node" "/usr/local/bin/npm"
"upgrade"
npm ERR! node v5.0.0
npm ERR! npm v3.3.9
npm ERR! code EREADFILE
npm ERR! Error extracting /Users/ekkis/.npm/slimerjs/0.9.5/package.tgz
archive: ENOENT: no such file or directory, open
'/Users/ekkis/.npm/slimerjs/0.9.5/package.tgz'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! [https://github.com/npm/npm/issues]
npm ERR! Please include the following file with any support request:
npm ERR! /Users/ekkis/Downloads/client-side-testing-0.1/npm-debug.log
I've tried uninstalling this slimerjs (whatever that is) both locally and globally but it still fails. if I look in the given directory there is indeed no 0.9.5 installed but I do find a 0.9.6
so what requires it and why isn't it satisfied with the later version? and most importantly, how do I fix it?
someone suggested 3.3.9 was rather behind the times. upgrading (now v.3.5.2) seemed to solve the problem:
sudo npm install -g npm
The problem is known in the NPM project here - https://github.com/npm/npm/issues/10057. There's an issue with npm#3.x when installing packages having "latest" set to a pre release version.
My fix was to downgrade npm to 2.14.10 - the latest stable in the 2.x series since there was no fix yet posted.
sudo npm install -g npm#2.14.10
for timebeing, Install specific version of slimmerjs eg. npm install slimerjs#0.9.5
https://github.com/graingert/slimerjs/issues/34

Resources