Suppose I am upgrading my node version from 14 LTS to 16.18.1 LTS version. After that I need to upgrade my react project node modules to latest & compatible versions.
Can anyone advice me how to find out compatible version of a node module for a given node version?
Hope I understood you correctly. you can use the npm view <package_name> command to see more information about what is required.
If you want to know what dependencies React 17.0.1 requires you can use these commands and get these outputs
npm view react#17.0.1 dependencies
{ 'loose-envify': '^1.1.0', 'object-assign': '^4.1.1' }
npm view react#17.0.1 engines
{ node: '>=0.10.0' }
Then you know you what dependency versions and node versions you require.
You can do the same with npm view <package> peerDependencies
Related
one of my friends sent me a project using react and node and i tried to run it with yarn. Each time i run this command i got this error : The engine "node" is incompatible with this module. Expected version "7.5.0". Got "15.13.0". I just want to know how update the react version of a project
Have a good day
You can change your package.json
"engines": { "node": ">=7.5.0"},
This will make the projects run with node 7.5.0 or newer versions. Also using nvm
nvm install version_you_want
nvm use version_you_want
Check node and npm versions
node -v
npm -v
Other option is to use
yarn install --ignore-engines
See this post: How to fix engine "node" version?
In my case I was gettin the same error because I didn't set the .env file
You could use this npm package, but be aware of breaking changes especially as it seems to be a very old version.
A better approach may be to use nvm - node version manager (or nvm-windows if that is your operating system) to install and use an older - compatible version of node, e.g. v7.5.0.
By Any chance is there anyway to check, node version and add dependencies accordingly.
For example in SPA, How I can check if node version-8, then during NPM install refer to "package-name":"8.0.1"
IF Node Version 10, then NPM INSTALL should refer to "package-name":"10.0.1"
If Node version 8, then NPM INSTALL should refer to "package-name":"8.0.1"
NPM supports an engines field in package.json. For example:
{ "engines" : { "node" : ">=10.3 <12" } }
Means that a package works on Node versions higher than 10.3 and lower than 12. When NPM performs package resolution it will attempt to use that field and resolve packages for you.
You can define your own package anup-dep-installer and publish two versions of it - one for Node 8 and one for Node 10 (specify the engines field). When you NPM install it it should pick the right one correctly.
Note that you shouldn't have to do this if the packages specify this automatically - and it is an extremely bad idea to include different packages on different node versions normally for anything other than compatibility reasons.
I am using nodist version 0.8.8 which is the latest one. By using this I installed latest node version 10.7.0 and latest NPM version 6.1.0. I assured it by reading the following document.
https://nodejs.org/en/download/releases/
Nw I surfed in Google to find whether NPM 6.2.0 is available? If it is I want to know the corresponding node version for it.
Node.js and NPM versions aren't directly connected, otherwise they would have matching versions.
Semantic versioning assumes that minor versions don't introduce breaking changes:
Given a version number MAJOR.MINOR.PATCH, increment the:
MAJOR version when you make incompatible API changes,
MINOR version when you add functionality in a backwards-compatible manner, and
PATCH version when you make backwards-compatible bug fixes.
This means that if NPM 6.1.0 works with Node 10.7.0, NPM 6.2.0 works with it, too.
Node version requirements are usually listed in package.json engines section, which can be checked locally or in GitHub repository.
npm package.json doesn't contain this section, so actual Node version that is suitable for it has to be deduced.
npm code base currently uses ES6 but no higher. Latest Node 6 release covers 99% of ES6 spec, it's expected that NPM 6.2.0 is fully workable with Node 6.14 or higher. Generally, it's certain that latest even major version (Node 10, as of now) doesn't have problems with latest NPM release.
You can use nvm which is node version manager
With nvm you have the option to install the latest npm compatible with your currently installed node
use this link to install nvm:
https://github.com/creationix/nvm
Node and npm are independent tools. You can very well install different versions of either.
Use
npm i -g npm#latest
to get the latest npm installed with your node.
use node -v and npm -v to get respective version informations.
I have a problem with npm install {moduleName}
previously, all my sub-dependencies were installed under {projectName}/node_modules/{moduleName}/node_modules/
After I upgraded to Node v5.0.0 (via installer on website), all my sub-dependencies are installed together with the dependencies under {projectName}/node_modules/
Why is that happening? And how can I change it back to the previous behavior?
Node v5.x comes with npm 3.x. This is the intended behavior in npm 3.x. You can read more about it in the npm 3.0.0 release notes, but here's the gist:
Your dependencies will now be installed maximally flat. Insofar as is possible, all of your dependencies, and their dependencies, and THEIR dependencies will be installed in your project's node_modules folder with no nesting. You'll only see modules nested underneath one another when two (or more) modules have conflicting dependencies.
I'm not sure why you'd want the old behavior—it was a dependency nightmare, hence the change—but if you really want to you can downgrade to npm 2.x:
$ npm install -g npm#latest-2
I installed it with
yaourt nodejs-cordova
I have the following settings:
node -v
v5.0.0
npm -v
3.3.10
which node
/usr/bin/node
which npm
/usr/bin/npm
Now I tried this:
sudo npm install -g cordova
But as result I get this:
npm WARN engine xmlbuilder#2.2.1: wanted: {"node":"0.8.x || 0.10.x"} (current: {"node":"5.0.0","npm":"3.3.10"})
/usr/bin/cordova -> /usr/lib/node_modules/cordova/bin/cordova
/usr/lib
└── cordova#5.3.3
Is it a version problem?
Can anyone help me?
Because now, when trying to create a new project I get this:
Creating a new cordova project.
Could not find directory: /usr/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/cordova-app-hello-world
It's hard to say with the output you've shown, but there is some dependency of cordova that is depending on an outdated version of xmlbuilder.
Newer versions of xmlbuilder use a different node version compatibility specifier:
"engines": {
"node": ">=0.8.0"
},
This makes it compatible with newer versions of node.js (including v5.0.0).
EDIT:
Here is the dependency tree for cordova. In there we see that the problematic dependency link goes like cordova#5.3.3 -> cordova-lib#5.3.3 -> plist#1.1.0 -> xmlbuilder#2.2.1. So then looking at each project in the chain, it's evident that several things need to happen:
An issue needs to be created at the plist issue tracker telling them to publish a new version because they already have their package.json pointing to the newer xmlbuilder with the fixed engines list.
After that is done, an issue needs to be created on the cordova issue tracker (requires a JIRA account there) telling them to update their dependency to use the newly published plist.
I found the solution on this site: https://ervinloh.wordpress.com/2015/06/07/solving-npm-warn-engine-cordova-js3-8-0-wanted-warning/
It is possible to force npm to install the newest Cordova version with:
npm install -g cordova#4
Doing this, everything works fine.