yarn
1.x installed through nix
issue (see issue)
- make sure to install
nixpkgs.yarn
&nixpkgs.fnm
(ornvm
) - Clone the repo
- Run
fnm use --install-if-missing
to install the version from.nvmrc
file - Validate that you get the correct version
node -v
&which node
should point to thenode
coming fromfnm
- Run
yarn start
, it shouldn't run & you will get this error
error nix-yarn-issue@1.0.0: The engine "node" is incompatible with this module. Expected version ">= 16". Got "14.18.1"
error Commands cannot run with an incompatible environment.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
- Run this command
yarn env | grep -E "\"(NODE|npm_node_execpath|npm_config_user_agent)\""
The output should look like this
"NODE": "/nix/store/d37aprv8pxqpslag1yq6n0q2q0fnpqwg-nodejs-14.18.1/bin/node",
"npm_node_execpath": "/nix/store/d37aprv8pxqpslag1yq6n0q2q0fnpqwg-nodejs-14.18.1/bin/node",
"npm_config_user_agent": "yarn/1.22.17 npm/? node/v14.18.1 darwin x64",
The problem is that nix
sets the NODE
environment variable to the nix
node
executable, which then yarn
picks up and sets
npm_node_execpath
to the same value.
This problem doesn't happen if yarn
is installed using homebrew
or directly
curl -o- -L https://yarnpkg.com/install.sh | bash
.