Do you want to request a feature or report a bug?
This is a bug report
What is the current behavior?
When node is not on the path, yarn's message is unintuitive to the point of directing a lot of effort into debugging the wrong problem:
bamboo@host:~$ node
The program 'node' is currently not installed. To run 'node' please ask your administrator to install the package 'nodejs-legacy'
bamboo@host:~$ yarn install
yarn install v1.3.2
warning You are using Node "4.2.6" which is not supported and may encounter bugs or unexpected behavior. Yarn supports the following semver range: "^4.8.0 || ^5.7.0 || ^6.2.2 || >=8.0.0"
If the current behavior is a bug, please provide the steps to reproduce.
See above... make sure node is not on the PATH and observe
What is the expected behavior?
yarn should report that it could not locate a node executable and report that error instead
Please mention your node.js, yarn and operating system version.
yarn: 1.3.2
OS: ubuntu
Uhh... Hmm... That error message comes from a JavaScript file, so Node must be on your path somewhere? Otherwise, that script wouldn't even be running. Furthermore, the version number it shows ("4.2.6" in this case) comes from the currently executing Node.js version: https://github.com/yarnpkg/yarn/blob/8918b6cff99e037f3ab56523ebfde96e0c19cdae/src/cli/index.js#L227
The message when Node.js is missing actually looks like this:
Yarn requires Node.js 4.0 or higher to be installed
See https://github.com/yarnpkg/yarn/blob/8918b6cff99e037f3ab56523ebfde96e0c19cdae/bin/yarn#L29:8
I agree with @Daniel15 , if that message was printed, then JS is executing, so Node _is_ on your path. If you cat yarn's main script file, you can see how it checks for node or nodejs executables:
command_exists() {
command -v "$1" >/dev/null 2>&1;
}
if command_exists node; then
if [ "$YARN_FORCE_WINPTY" = 1 ] || command_exists winpty && test -t 1; then
winpty node "$basedir/yarn.js" "$@"
else
exec node "$basedir/yarn.js" "$@"
fi
ret=$?
# Debian and Ubuntu use "nodejs" as the name of the binary, not "node", so we
# search for that too. See:
# https://lists.debian.org/debian-devel-announce/2012/07/msg00002.html
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=614907
elif command_exists nodejs; then
exec nodejs "$basedir/yarn.js" "$@"
ret=$?
else
echo 'Yarn requires Node.js 4.0 or higher to be installed.'
ret=1
fi
If neither os found then you would get 'Yarn requires Node.js 4.0 or higher to be installed.'
for what it's worth, i have the same problem, looks like node is being run from /usr/bin/nodejs
So what DOES the error mean? There are no useful resources that I can find anywhere on the web to resolving this warning. Thanks in advance
The error message means your Node.js version is too old.
Sent from my phone.
On Sat, May 5, 2018, 1:58 PM Jason Hollister notifications@github.com
wrote:
So what DOES the error mean? There are no useful resources that I can find
anywhere on the web to resolving this warning.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/yarnpkg/yarn/issues/4961#issuecomment-386776995, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAFnHajoMu8xGq6XTQTcvM6eGoZP679Yks5tvSOCgaJpZM4Qjdx3
.
This can't be the case - I have this problem and I don't even have node 4.2.6 installed. Here is my nvm ls:
nvm ls
-> v8.9.4
default -> 8.9.4 (-> v8.9.4)
node -> stable (-> v8.9.4) (default)
stable -> 8.9 (-> v8.9.4) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> v8.9.4)
lts/argon -> v4.8.7 (-> N/A)
lts/boron -> v6.12.3 (-> N/A)
lts/carbon -> v8.9.4
Yet when I run yarn install I get:
warning You are using Node "4.2.6" which is not supported and may encounter bugs or unexpected behavior. Yarn supports the following semver range: "^4.8.0 || ^5.7.0 || ^6.2.2 || >=8.0.0"
And it fails on packages that require higher versions. Any ideas?
I don't even have node 4.2.6 installed.
@bportman - It must be installed somewhere. The version number comes from process.versions.node, which comes directly from Node.js: https://github.com/yarnpkg/yarn/blob/28c89216e63ca267e2b5fdcf3662860ca8b81282/src/cli/index.js#L228
It seems I first installed node on Ubuntu with sudo apt-get install nodejs, and it automatically gives you 4.2.6. Then I separately installed node (different repo from nodejs I guess) with a newer version. Been using the newer version except yarn uses nodejs, not node. Was able to uninstall and use a PPA to install nodejs 8.11 something and now I'm good.
Ubuntu 16.04 I ran into the same problem and I found the solution on this page:
https://goo.gl/2FFjHG
I'm sure this works for several versions of Ubuntu
It is Answer # 126
You can check it for more detail, but here is the short answer.
Create a new file: /etc/apt/sources.list.d/nodesource.list
and insert the following text into the nodesource.list file:
deb https://deb.nodesource.com/node_6.x xenial main
deb-src https://deb.nodesource.com/node_6.x xenial main
Then, save the file. (replace node_6.x with node_7.x or node_8.x, etc.for newer Node versions)
I used node_10.x
Download the GPG Signing Key from Nodesource for the repository. Otherwise, you may get NO_PUBKEY errors with apt-get update:
which you may have already done if you are having this problem, but here it is if you need it:
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -
Run sudo apt-get update.
Run apt-cache policy nodejs
output should be:
Version table:
6.2.1-1nodesource1~xenial1 500
500 https://deb.nodesource.com/node_6.x xenial/main amd64 Packages
4.2.6~dfsg-1ubuntu4 500
500 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
should have: node_6.x with node_7.x or node_8.x, or whatever version you put in nodesource.list file.
If you do not see entries like this, and only see 4.2.6, start over. Otherwise, proceed.
Install nodejs
sudo apt-get install nodejs
Check nodejs version
node --version
Should be whatever version you put in nodesource.list. If not start again from beginning and check your work.
This happened to me with Ubuntu as operating system:
The way that I've solve it was uninstalling node from synaptic and I ran again the npm init command
Most helpful comment
for what it's worth, i have the same problem, looks like node is being run from /usr/bin/nodejs