Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency between node versions of npm and yarn #812

Closed
hiendv opened this issue Oct 12, 2016 · 25 comments
Closed

Inconsistency between node versions of npm and yarn #812

hiendv opened this issue Oct 12, 2016 · 25 comments

Comments

@hiendv
Copy link
Contributor

hiendv commented Oct 12, 2016

Do you want to request a feature or report a bug? Reporting a bug

What is the current behavior? Inconsistency between the version of node which yarn's running on and the current version of node (node --version) may cause errors like

The engine "node" is incompatible with this module. Expected version ">=4.5.0".

If the current behavior is a bug, please provide the steps to reproduce.

  • Using nvm or having another version of node rather than the shipped version with yarn installation.
  • Determining the version of Node which yarn uses. E.g. vim $(which yarn)
console.log(process.versions.node) // for me, the output was 4.2.6 while `node -v` gave v6.7.0

These versions should be different.

  • yarn add any packages whose engine requirement is satisfied by only one of these two

What is the expected behavior?
Yarn should share the same version of node engine.

Please mention your node.js, yarn and operating system version.
node -v: 6.7.0
npm -v: 3.10.8
yarn --version: 0.15.0 which is installed via the Debian package repository
OS: Ubuntu 16.04.1 LTS

Current workaround
Using npm i -g yarn

@hiendv
Copy link
Contributor Author

hiendv commented Oct 12, 2016

From my point of view, there should be a heads-up in Installation documentation when installing yarn using package repositories.

@leebenson
Copy link

@hiendv - did npm i -g yarn solve it for you? I'm getting this error even installing globally/directly from npm.

@hiendv
Copy link
Contributor Author

hiendv commented Oct 12, 2016

@leebenson It actually did. Could you please post the results of which yarn and which node?

@leebenson
Copy link

leebenson commented Oct 12, 2016

which yarn

/usr/local/bin/yarn

which node

/usr/local/bin/node

yarn --version

0.15.1

node --version

v6.7.0

On MacOS Sierra 10.12.1 Beta

@hiendv
Copy link
Contributor Author

hiendv commented Oct 12, 2016

@leebenson

  • Try
vim $(which yarn)
  • Search for a line look like this var ver = process.versions.node; and print the ver out
var ver = process.versions.node;
console.log(ver)
  • Try yarn install again and compare ver to node -v

@leebenson
Copy link

leebenson commented Oct 12, 2016

var ver = process.versions.node;
console.log('ver ->', ver);

Executing yarn:

ver -> 6.7.0
yarn install v0.15.1
info No lockfile found.
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
error [email protected]: The engine "node" is incompatible with this module. Expected version "^5.3".
error Found incompatible module
info Visit http://yarnpkg.com/en/docs/cli/install for documentation about this command.

Same problem.

@hiendv
Copy link
Contributor Author

hiendv commented Oct 12, 2016

Interesting. Your case is different.
1. Why?
[email protected] specifies

"engines": {
    "node": "^5.3",
    "npm": "^3.5"
}

which is totally incompatible with your node v6.7.0. It's because of the package itself. However, the author already fixed it in the next release.
2. How to resolve?
Use [email protected] instead

"engines": {
    "node": ">= 5.3",
    "npm": ">= 3.5"
 }

@leebenson
Copy link

nicely spotted! Thanks @hiendv

I've asked the parent package to bump.

I'll look for the patch mentioned here to land too, which should help workaround the issue of deeply nested dependencies with broken engines configs.

@hiendv
Copy link
Contributor Author

hiendv commented Oct 12, 2016

You're welcome @leebenson.
Let's hope yarn team will look into my problem soon ;)

@hiendv
Copy link
Contributor Author

hiendv commented Oct 13, 2016

The main difference is that npm is shipped with node while yarn isn't.

@hiendv
Copy link
Contributor Author

hiendv commented Oct 13, 2016

There's a note about configuring the NodeSource repository but I don't think it's stated clearly and correctly enough.

On Ubuntu 14.04 and Debian Stable, you will also need to configure the NodeSource repository to get a new enough version of Node.js (Debian Testing and Ubuntu 16.04 come packaged with a sufficient version of Node.js, so this step is not required in those environments)

It's true to say if we install nodejs from the NodeSource repository and use it (e.g. /usr/bin/nodejs), we can install yarn from Yarn repository and use it properly. But this is mandatory because there shouldn't be any difference between the version of engine between npm install and yarn install/add

If a user uses another version of node (and npm), e.g. ~/.nvm/versions/node/v6.7.0/bin/node, there will be inconsistency.

@terion-name
Copy link

@leebenson what is strange that quill bumped dependency to [email protected] (seen https://github.com/quilljs/quill/blob/develop/package.json), but yarn add quill, yarn add [email protected] or even yarn add https://github.com/quilljs/quill.gitseems to still load older version and tries to require [email protected] (and fails). I've cleared yarn cache — did not help (

@Daniel15
Copy link
Member

Daniel15 commented Oct 17, 2016

Inconsistency between the version of node which yarn's running on and the current version of node (node --version) may cause errors like
The engine "node" is incompatible with this module. Expected version ">=4.5.0".

This sounds confusing... Is it intentional that you have two different Node.js versions? I'd suggest just having a single version of Node.js installed 😄

Is there an issue with our Debian package that's causing it to use the wrong Node.js version?

@jamiebuilds
Copy link
Contributor

@Daniel15 do some of the install options come with a specific version of node?

@Daniel15
Copy link
Member

Daniel15 commented Oct 17, 2016

@thejameskyle None of them are bundled with Node. The Debian/Ubuntu package "recommends" the nodejs package (so nodejs will be installed unless the user opts-out from installing recommended packages), but it's not a strict dependency, so users can just install Yarn and use their own Node.js version through nvm or whatever.

Windows installer doesn't check for Node any more, so Yarn will just fail to run if they install Yarn but don't install Node.js.

@Daniel15
Copy link
Member

Daniel15 commented Oct 17, 2016

Going to close this out as #1142 should help with inconsistencies around Node.js in Debian.

@hiendv - To fix your current situation, I think you should apt-get remove nodejs and then symlink /usr/bin/nodejs to whatever version of Node you're using (probably /usr/bin/node or /usr/local/bin/node).

I think the ideal fix is to use the native package management system of your operating system rather than using nvm, unless you have a specific reason to use nvm (eg. if you require multiple versions of Node.js to be installed and accessible).

@chmac
Copy link

chmac commented Aug 9, 2017

I think I have the same issue as described here. I do indeed have multiple versions of node installed and it's a hard requirement. We're using meteor which installs its own version of node depending on the meteor version of a given project. We're switching to yarn instead of npm, and in the process, hitting the "error Found incompatible module" error.

error [email protected]: The engine "node" is incompatible with this module. Expected version ">=6".
error Found incompatible module

Here's some additional info to complicate matters:

$ meteor npm -v
4.4.4
$ npm -v
4.6.1
$ meteor node -v
v4.8.1
$ node -v
v7.7.3
$ meteor yarn --version
0.27.5

When I try to run yarn in my project (which did successfully run yesterday) I get the following:

meteor yarn                                                                                                 
yarn install v0.27.5
[1/4] Resolving packages...
[2/4] Fetching packages...
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=6".
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

The react-jsonschema-form packages at version 0.49.0 has an "engines" section which includes "node": ">=6". The version of node that meteor is running is 4.8.1 which is indeed below 6. However, yarn won't install anything because it hits this error and bails.

I can workaround it with yarn --ignore-engines but that's definitely not a solution. I can't reopen this issue, hopefully @Daniel15 or @hiendv will do that as I'd argue this is definitely an issue, and definitely requires a solution. Perhaps adding a way to tell yarn which engine versions it should calculate based on?

@hiendv
Copy link
Contributor Author

hiendv commented Aug 9, 2017

Although my opinion remains, I cannot reopen the issue. Looking forward to hearing from @Daniel15

@Daniel15
Copy link
Member

Daniel15 commented Aug 9, 2017

I do indeed have multiple versions of node installed and it's a hard requirement.

Just put your 'preferred' version of Node (ideally the newer one) earlier in your $PATH than the other version.

The react-jsonschema-form packages at version 0.49.0 has an "engines" section which includes "node": ">=6". The version of node that meteor is running is 4.8.1 which is indeed below 6. However, yarn won't install anything because it hits this error and bails.

It's working as expected then? If the package specifies that it only works on Node 6 and above, it should indeed fail on Node 4.8.1. Sorry if I'm missing something here. If the package works on an older version, they should not have that section in the package.json.

@chmac
Copy link

chmac commented Aug 10, 2017

@Daniel15 Haha, you're right, that is a greater than, not a less than! It's not always possible to change the $PATH. In our case, it's modified by both meteor and npm, which is why we can install yarn as a local dependency without having to install it system wide.

@Daniel15
Copy link
Member

Can Meteor upgrade its archaic Node.js version to a more modern one? I feel like this is actually a Meteor issue and not a Yarn issue.

@chmac
Copy link

chmac commented Aug 14, 2017

@Daniel15: The next release will upgrade node, but I think the more general use case of specifying which version of node yarn should consider as "installed" is what's at issue here. In my opinion, it's a very valid scenario to have multiple versions of node installed and to want to specify which one yarn should use for engines checks.

@Daniel15
Copy link
Member

it's a very valid scenario to have multiple versions of node installed and to want to specify which one yarn should use for engines checks.

How would you specify which one to use though?

I agree that it's a valid scenario to have multiple versions of Node.js installed, however I feel like it's extremely uncommon to run one version of Node.js while installing packages for a totally different version of Node.js (eg. using Node 4 to install packages that will actually be used on Node 6) 😃

@chmac
Copy link

chmac commented Aug 15, 2017

@Daniel15 Hmm, yes, you're right. Makes sense. Fair point. I was going to write up a feature request to specify which version of node should be considered for engine checks, but actually, you make an excellent point. I think this whole thing started because I misread the version constraint and thought something weird was happening, but it wasn't. Sorry for the noise, thanks for the patience.

@sharanainapurapu
Copy link

sharanainapurapu commented Apr 1, 2019

It worked for me after I installed latest stable version of node ( https://nodejs.org/en/ )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants