npm outdated and npm update doesn't work - node.js

I want to check if my modules are Latest
i do: sudo npm outdated
and I have this results
Package Current Wanted Latest Location
oauth 0.9.9 0.9.9 0.9.10 twit > oauth
require-all 0.0.3 0.0.3 0.0.8 mysql > require-all
bignumber.js 1.0.1 1.0.1 1.3.0 mysql > bignumber.js
request 2.27.0 2.27.0 2.30.0 facebook-chat > node-xmpp > node-xmpp-client > request
through 2.2.7 2.2.7 2.3.4 facebook-chat > node-xmpp > brfs > through
then i do this:sudo npm update
but if I repeat sudo npm outdated i have the same results...
also if I do for example
Info:
Package Current Wanted Latest Location
oauth 0.9.9 0.9.9 0.9.10 twit > oauth
Then Update
sudo npm update oauth
Then
sudo npm outdated oauth
My Result:
Package Current Wanted Latest Location
oauth 0.9.9 0.9.9 0.9.10 twit > oauth

Your project is actually as up-to-date as it can be currently.
NPM won't simply install the Latest version of a package unless that version is also Wanted.
The resulting field 'wanted' shows the latest version according to the version specified in the package.json, [...]
And, for each that you listed, the Wanted and Current versions already match.
Package Current Wanted ...
oauth 0.9.9 0.9.9 ...
require-all 0.0.3 0.0.3 ...
bignumber.js 1.0.1 1.0.1 ...
request 2.27.0 2.27.0 ...
through 2.2.7 2.2.7 ...
An attempt to force oauth to its current Latest of 0.9.10, for example, would actually be considered invalid as twit has 0.9.9 listed exactly:
"dependencies": {
"oauth": "0.9.9"
},
$ npm ls
...
└─┬ twit#1.1.11
└── oauth#0.9.10 invalid
npm ERR! invalid: oauth#0.9.10 ...\node_modules\twit\node_modules\oauth

Check your package.json may be your packages or there there.
try to install package with --save and try it will work
example :
npm install underscore#1.5.0 --save
now try
npm outdated

Related

Does npm automcatically download a version that is compatible with the Node version on the local computer?

Does npm automatically download the version of the library that is compatible with the Nodejs environment?
Suppose the most recent version is only compatible with Nodejs18 or above but the Nodejs version on my computer is v14. When I run npm i <library>, does npm automatically download a version of the library that is compatible with Node14, or do I have to manually lookup a version and run npm i <library>#version?
No it doesn't.
If you run npm i <library> it will pull in the latest version of the library irrespective of which version of Node you have on your machine. To install a specific version of the library you will need to run npm i <library>#version.
We can actually prove that this is the case. The jsdom package upped its required Node version from v12 to v14 when it released version 20.0. You can see the release notes here.
The way that a package specifies the supported version of Node is through an engines property in the package.json file.
Version 19 (link):
"engines": {
"node": ">=12"
}
Version 20 (link):
"engines": {
"node": ">=14"
}
So with the latest version of Node:
$ node -v
v19.6.0
$ npm i jsdom
...
$ cat package.json | grep jsdom
"jsdom": "^21.1.0"
As expected, the latest version of jsdom is installed.
Then, using nvm to change Node version:
$ nvm install v12
Now using node v12.22.12 (npm v6.14.16)
$ node -v
v12.22.12
$ npm init -y
...
$ npm i jsdom
...
$ cat package.json | grep jsdom
"jsdom": "^21.1.0"
As you can see, this has still pulled in the latest version of jsdom, despite me running a version of Node that the current jsdom doesn't support.

Install Node in ubuntu

I want to install node to run Angular2 program, but while installing I am getting this error:
npm WARN npm npm does not support Node.js v0.10.25
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 You can find the latest version at https://nodejs.org/
npm WARN using --force I sure hope you know what you are doing.
/usr/local/lib/node_modules/npm/lib/cache.js:3
const BB = require('bluebird')
^^^^^
npm ERR! Use of const in strict mode.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/swapnily/.npm/_logs/2017-07-04T10_51_42_147Z-debug.log
I've already tried this solution:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
but even for first command "sudo npm cache clean -f" I am getting same issue. Please let me know if anyone aware about same.
I, personally, am a huge fan of nvm.
It makes node installation and versions manipulations so easy.
All install instructions can be found here.
I'll just give an example command of installing new nodejs version and start using it, so you understand how clear and easy it is:
nvm install 8.0
nvm use 8.0
I suggest you download the Node archive from official site(https://nodejs.org/en/)
After that, you need the create a soft link to the bin file you just download from the site, the command line words may like this:
ln -s /opt/node-v6.10.2-linux-x64/bin/node /usr/bin/node
Same for npm
$ sudo apt update
$ sudo apt install node.js
To check the version of Node:
$node -v
Installing Using a PPA; to get recent version of Node.js you can add the PPA (personal package archive) maintained by NodeSource. This will have more up-to-date version of Node.js than the official ubuntu repositories, and will allow you to choose between Node.js c6.x (which is supported until April of 2019), Node.js v8.x (the current LTS version, supported until December of 2019), and Node.js v10.x (the latest version, supported until April of 2021).
First, install the PPa in order to get access to its contents. From your home directory, use curl to retrieve the installation scripts for your preferre version, making sure to replace 8.X with your preferred version string (if different)
Check this link to continue: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04?

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.

Grunt not being found when installing grunt-sass with Node.js via Git Bash on Windows 10

I am following a course on Lynda.com on using Node.js to download packages etc.
I have followed the instructions completely.
I have installed the latest version of Node.js,
Via Git Bash I have installed the latest version of Grunt as follows
Nicholas#NicksDesktop MINGW64 /
$ npm install -g grunt cli
C:\Users\Nicholas\AppData\Roaming\npm\grunt -> C:\Users\Nicholas\AppData\Roaming\npm\node_modules\grunt\bin\grunt
C:\Users\Nicholas\AppData\Roaming\npm
+-- cli#1.0.1
`-- grunt#1.0.1
When I enter the following via Git Bash
npm install --save grunt-sass
I get the following error
npm WARN grunt-sass#2.0.0 requires a peer of grunt#>=0.4.0 but none was installed.
How can I fix this?
I navigated to the folder where grunt-sass is installed via Git Bash and then entered
npm install grunt#0.4.0
This seems to fix the errors, it seems that after this both a up to date version are installed and the required older version.

Why "wanted" is not "latest"?

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.

Resources