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

yarn install with nvm #6667

Open
JustOneJance opened this issue Nov 13, 2018 · 7 comments
Open

yarn install with nvm #6667

JustOneJance opened this issue Nov 13, 2018 · 7 comments
Assignees
Labels

Comments

@JustOneJance
Copy link

JustOneJance commented Nov 13, 2018

i use Ubuntu

I have nvm:

nvm ls
v8.11.3
v8.11.4
-> v11.1.0
default -> 8.11.4 (-> v8.11.4)
node -> stable (-> v11.1.0) (default)
stable -> 11.1 (-> v11.1.0) (default)
I installed yarn with:

sudo apt-get install --no-install-recommends yarn
I also added in .bashrc alias node=nodejs. But when I try yarn install I see:

Yarn requires Node.js 4.0 or higher to be installed.
How can I fix it?
it happend only in my project. Which i download from gitlub.
package.json
"scripts": {
"test": "echo "Error: no test specified" && exit 1",
"preinstall": "sudo yarn global add prettifier eslint flow-bin",
"babel": "babel",
"dev": "webpack-dev-server",
"lint": "eslint",
"validate": "yarn list",
"prettify": "./node_modules/prettifier/bin/prettifier.js",
"precommit": "lint-staged",
"fmt": "prettier --write './**/.js'"
},
"devDependencies": {
"@babel/cli": "^7.1.5",
"@babel/core": "^7.1.2",
"@babel/node": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-flow": "^7.0.0",
"@webpack-contrib/config-loader": "^1.2.1",
"autoprefixer": "^9.3.1",
"babel-cli": "^6.26.0",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.4",
"babel-preset-react": "^6.24.1",
"css-loader": "^1.0.1",
"eslint": "^5.8.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-flowtype": "^3.2.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1",
"flow-typed": "^2.5.1",
"husky": "^1.1.3",
"lint-staged": "^8.0.4",
"mini-css-extract-plugin": "^0.4.4",
"node-sass": "^4.10.0",
"postcss-loader": "^3.0.0",
"precommit-hook": "^3.0.0",
"prettier": "^1.15.2",
"react": "^16.6.0",
"react-dom": "^16.6.0",
"react-hot-loader": "^4.3.12",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"webpack": "^4.25.1",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.10"
},
"dependencies": {
"babel-preset-flow": "^6.23.0",
"flow-bin": "^0.85.0",
"uglifyjs-webpack-plugin": "^2.0.1"
},
"pre-commit": [
"lint",
"validate",
"flow check"
],
"lint-staged": {
"
.js": [
"prettier --write",
"git add"
]
},

@ghost ghost assigned torifat Nov 13, 2018
@ghost ghost added the triaged label Nov 13, 2018
@shawnolson-fp
Copy link

Duplicate of #2821

@rally25rs
Copy link
Contributor

Not sure if this will be helpful, but that output comes from this shell script https://github.com/yarnpkg/yarn/blob/master/bin/yarn#L31

specifically it uses command -v node and command -v nodejs so you could make sure that that command knows where to find node.

as example output, on OSX using nvm I get:

~/Projects/yarn-test2 🐒   command -v node
/Users/jvalore/.nvm/versions/node/v8.10.0/bin/node

@gromov-io
Copy link

Не уверен, что это будет полезно, но этот вывод получен из этого сценария оболочки https://github.com/yarnpkg/yarn/blob/master/bin/yarn#L31

в частности, он использует, command -v nodeи command -v nodejsпоэтому вы можете убедиться, что он commandзнает, где найти узел.

В качестве примера вывода на OSX с использованием nvmя получаю:

~/Projects/yarn-test2 🐒   command -v node
/Users/jvalore/.nvm/versions/node/v8.10.0/bin/node

/home/dev/.nvm/versions/node/v12.14.0/bin/node

mi error: Yarn requires Node.js 4.0 or higher to be installed.

@maghost
Copy link

maghost commented Jan 19, 2020

Here I got this error because my .zshrc file was configured to set Yarn in PATH before configuring NVM. To fix this, I changed the line export PATH="$(yarn global bin):$PATH to stay after the NVM/NPM settings.

@peakercope
Copy link

@JustOneJance I have similar problem and how I can investigated it related with husky. When I'm trying to commit from Webstorm it shows me error Yarn requires Node.js 4.0 or higher to be installed. but commit form terminal works Ok.

@peakercope
Copy link

peakercope commented Jan 31, 2020

For me I found the solution:
create file ~/.huskyrc with the following content

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

as it described here https://github.com/typicode/husky#node-version-managers

@mkraenz
Copy link

mkraenz commented Sep 8, 2021

For me I found the solution:
create file ~/.huskyrc with the following content

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

as it described here https://github.com/typicode/husky#node-version-managers

September 2021 update on @peakercope:
Solution is still working but the reference link has changed to https://typicode.github.io/husky/#/?id=command-not-found

Note that the file must be in your user's home directory ~ (not in the repository)

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

No branches or pull requests

8 participants