Why "wanted" is not "latest"? - node.js

I am using npm outdated -g --depth=0 to see which globally installed packages have newer version. I am getting this:
$ npm outdated -g --depth=0
Package Current Wanted Latest Location
bower 1.6.8 1.6.8 1.7.1
jshint 2.8.0 2.8.0 2.9.1-rc2
jspm 0.16.13 0.16.13 0.16.19
npm-windows-upgrade 1.0.1 1.0.1 1.2.0
typescript 1.7.3 1.7.3 1.7.5
I can not update any of those packages. npm update -g does nothing. Why Wanted field is has lower version than Latest? I am using windows 7, node 4.2.1 and npm 3.5.2

Since these are global packages there is no package.json to direct their update policy. By default "wanted" version is the same as installed or "current" for global packages. That means npm update will not update them saying that they are at the most recent wanted version.
In order to update them use npm -g install .... Install will use "latest" version from the repository.

npm update -g shouldn't do "nothing" -- you should try npm update -g --verbose and see what that has to say.
I've had to run npm update -g a few times in succession to get it to update everything to the latest.

I just ran into this same issue and had a different solution not yet mentioned. My issue was that my package.json had semantic versioning constraints associated with versions. Given your package bower, for example, with a current/wanted version and of 1.6.8 and a latest version of 1.7.1, it could be possible that your package.json file shows:
"dependencies": {
"bower": "~1.6",
}
Running npm update bower would not update bower past version 1.6 to version 1.7 because of the ~ prefix; to get around this you can run npm install bower#latest to bypass the semantic versioning constraints.

Related

Correct update nodejs and npm

i am working on nuxtjs project since node v14 version. and now node is version v16. and I'm trying to update node to version v16. but after that my nuxt project error.
I'm confused, should I stick with v14 or upgrade?
what is the best way to update?
It is recommended to update to get the latest features and security updates.
To update Node.js and npm, go to nodejs.org, download, and run the installer. The Node Package Manager should automatically be installed too.
Also, don't worry about removing the previous version; the installer takes care of that too.
To update your dependencies, update the dependencies and devDependencies fields to be the latest versions. For Nuxt.js, the latest version (at the time posted) is v2.15.8.
You can also use npm-check-updates to check for updates for all of your dependencies. Run the following commands to use it (running it in your project root directory).
$ npm install -g npm-check-updates
$ ncu -u
$ npm install
ncu is the command for npm-check-updates.
Also, you can update all of your dependencies manually to have the asterisk instead of the version, as so.
{
"dependencies": {
"nuxt": "*"
}
}
So, every time you run the command below, it will update the dependencies to the latest version.
$ npm install
You can do it by installing n:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
It will install the current stable version of node.

Specific Angular Cli Version is not installed

I need to install Angular CLI in the version 1.6.8. When I am executing this command:
npm install -g #angular/cli#1.6.8
it is getting installed well. But when I am check the version using ng -v, it displays the latest version, in my case 1.7.4.
For my code compatibility, I need version 1.6.8. And even in my dependencies in package.json, I have specified the cli as version 1.6.8 :
"#angular/cli": "^1.6.8"
Does anybody know the issue? How can I install version 1.6.8?
if you are inside a directory that has node_modules ng -v would report that version, not the global one. For updating your global CLI, move to a directory that doesn't have node_modules installed and then execute
npm uninstall -g #angular-cli
npm cache clean
npm install -g #angular/cli#1.6.8
You can change the version of the angular-cli in the package.json if you want to stick to the particular version remove the ^ symbol but this would be local
"#angular/cli": "1.6.8"
^ it means update the minor and patch version to the latest and keep the major version same.
This command will install the CLI globally on your machine.
npm install -g #angular/cli#1.6.8
So, if you have an application that already has CLI version 1.7.4 included in it, you will see that version when you run ng -v. If you would like to downgrade to an earlier version, change the version in the package.json to the exact version you would like to use, and run npm install.
In your package.json you have this:
"#angular/cli": "^1.6.8"
What you need to change it to is this:
"#angular/cli": "1.6.8"
Remove the caret from the version number.
The caret tells npm that is can install versions of a library higher than what is listed, but only if the version is a minor or patch change. So, going from version 1.6.8 to 1.7.4 is OK, but it won't jump to version 6.0.0 when that comes out.
See here for more details.

NPM install package compatible with specific version of another package

My package depends on PackageA. PackageA depends on PackageB_Version2. I now need to install PackageC which depends on PackageB. How can I force npm to install that PackageC which is compatible with existing version of PackageB (i.e., PackageB_Version2)?
NPM will install a version specific packaging you tell it the version #. From the docs:
npm install [<#scope>/]<name>#<version>
npm install [<#scope>/]<name>#<version range>
So once you determine the version numbers and dependencies install with save to package.json and you will have your version dependencies saved until you update them.

npm update to specific version (and shrinkwrap)

I'm using NPM and shrinkwrap (latest up to date version) to maintain my packages.
At the moment, one of my package current version is 1.1.0.
The latest version of this package is 2.2.0.
I want to update/upgrade this specific package to version 2.0.0 (and not the latest 2.2.0).
I thought that the procedure would be:
npm install in order to make sure that I'm synchronized with the npm-shrinkwrap
npm update myPackage#2.0.0
npm shrinkwrap
git add . && git commit -m "Updating package myPackage to version 2.0.0"
This doesn't seem to be the right road to go. It doesn't update the package.json and it always jump to the latest version. I have no control over this command to select the specific version I want.
I read the documentation about npm update and couldn't find the proper way to update the package to a specific version.
How to do this ? Would npm install --save myPackage#2.0.0 would be the correct procedure ? Then what will be the purpose of having npm update command ?
Solution:
npm install package#2.0.0 --save
npm update doesn't seem to interact with the shrinkwrap file as far as I can tell. But you can use npm install to set the version of a package.
This will update both package.json and npm-shrinkwrap.json:
npm install myPackage#2.0.0 --save
You can enter to package.jsonand write the version yourself on the dependencies. After that do npm install and it will install the correct version.

Phonegap installation failure. Sticking to version 0.9.4 by default

Ive been trying to install phonegap for hours now. For some reason by default it installs version 0.9.4 (when I do npm install -g phonegap). If I specify to use latest version (npm install -g phonegap#5.0.0-0.28.1) I get tonns of errors for almost every dependency out there. Tried reinstalling node, removing modules, clearing npm cache, etc.
Windows 7
Node version 0.12.5 (x64)
Npm version 2.11.2
I had this problem before with my Mac
to fix this, i just simply ran
npm update -g phonegap
and behold it updated itself to 5.0.0

Resources