lint-staged requires at least version 6 of Node, please upgrade
I am on the (very new) Node version 10.0.0.
Install lint-staged 7.0.4 and Node 10.0.0 and attempt to use lint-staged e.g. in a precommit hook.
$ ./node_modules/.bin/lint-staged --debug
lint-staged requires at least version 6 of Node, please upgrade
lint-staged: v7.0.4Tracked down the bug to the use of please-upgrade-node. Relevant issue.
Today I also encountered this problem after updating node.js to v10
me too
me too, windows 10
https://github.com/typicode/please-upgrade-node/pull/10 has been open since Nov 17, 2017. lint-staged should remove this dependency and rely on engine: node in package.json instead.
+1
I'd accept a pull request which removes the dependency(i am on a vacation of sorts and I have limited access to the internet). I think it served its purpose while we removed support for node 4 and could be removed now. It'd result in a slightly less friendly error message for older node versions bit that should be okay.
Closed since please-upgrade-node is now fixed.
For future googlers:
The fix for node v10 is to update lint-staged to ^7.0.5
yarn add --dev lint-staged@^7.0.5
or
npm install --dev lint-staged@^7.0.5
@jesstelford's fix doesn't work for me, I had to do this:
git commit --no-verify -m "commit messsage"
@animaonline That's not really a fix. You are just skipping the pre-commit hook. Could you please check and report the exact version of lint-staged that you have installed? npm ls lint-staged will print the version being used in your project.
โโโ [email protected]
I failed to reproduce the issue using a fresh project:
โ node --version
v10.0.0
lint-staged-node-10 on ๎ master [+] is ๐ฆ v1.0.0 via โฌข v10.0.0
โ ./node_modules/.bin/lint-staged --debug
lint-staged:bin Running `[email protected]` +0ms
lint-staged Loading config using `cosmiconfig` +0ms
lint-staged Successfully loaded config from `/home/suhaskaranth/dev/playground/lint-staged-node-10/package.json`:
lint-staged { '*.js': 'echo' } +2ms
lint-staged:cfg Normalizing config +0ms
lint-staged:cfg Validating config +2ms
Running lint-staged with the following config:
{
linters: {
'*.js': 'echo'
},
concurrent: true,
chunkSize: 9007199254740991,
globOptions: {
matchBase: true,
dot: true
},
ignore: [],
subTaskConcurrency: 1,
renderer: 'verbose'
}
lint-staged:run Running all linter scripts +0ms
lint-staged:run Resolved git directory to be `/home/suhaskaranth/dev/playground/lint-staged-node-10` +0ms
lint-staged:run Loaded list of staged files in git:
lint-staged:run [ 'yarn.lock', 'package.json', '.gitignore' ] +14ms
lint-staged:gen-tasks Generating linter tasks +0ms
lint-staged:cfg Normalizing config +19ms
lint-staged:gen-tasks Generated task:
lint-staged:gen-tasks { pattern: '*.js', commands: 'echo', fileList: [] } +13ms
Running tasks for *.js [started]
Running tasks for *.js [skipped]
โ No staged files match *.js
lint-staged linters were executed successfully! +39ms
Could you ensure that the version of please-upgrade-node that you have installed is 3.0.2? If not, running npm i or yarn _should_ fix it.
Is this confirmed to be fixed?
With lint-staged 7.0.0 I used to see: "lint-staged requires at least version 6 of Node, please upgrade"
Then I updated to latest [email protected] and now i see: "cosmiconfig requires at least version 4 of Node, please upgrade" and "cosmiconfig" is a dependency on lint-staged....

@mattmazzola Yes, this is confirmed to be fixed. I am suspecting that your dependencies are not installed correctly. [email protected] depends on cosmiconfig with ^5.0.2. And this version of cosmiconfig doesn't depend on please-upgrade-node at all. Which means that you have [email protected] in your node_modules. I think rm -rf node_modules package-lock.json && npm i should fix the issue.
Edit: I might be wrong about the incorrect version installed for lint-staged. cosmiconfig is used by multiple packages, one of which could be using the older version. Nevertheless, nuking your See https://github.com/alexjoverm/typescript-library-starter/issues/220#issuecomment-394223628.node_modules, lock file and running install again could fix this issue.
I don't understand how it can be "not installed correctly". Deleting package-lock.json works, but it's not a safe/recommendable operation.
I cloned the effected repo twice. In one I preserved the package-lock.json and the other deleted it.
After npm install both resolve to cosmiconfig 5.0.5 yet the one with original package-lock.json fails as if it's still somehow using older version. ๐
Anyways, unblocked now. Thank for confirming.
As I mentioned in the comment linked above, the issue stems from the specific version of prettier which npm installs when the lock file is present.
Is this issue fixed?
@manjula91, no. On Win10 and Node10 I had the same issue.
https://github.com/okonet/lint-staged/issues/432#issuecomment-385586407 seems to help but it looks like an ugly hack.
It's not a hack. It's what you need to do to pull in the package versions which fix the issue.
Yeah. You're right. I didn't notice that I had the lint-staged package in deps. Bump the version solved my issue.
Removing node_modules and reinstalling it should fix it:
rm-r node_modules
npm install
cool fixes on my end tooo ๐
As I don't see this mentioned here: this could be related to using a husky precommit hook alongside nvm. For some odd reason husky doesn't use the version nvm is _currently_ using but instead uses nvm's default version. More about the issue can be found here.
Fix for me was to set nvm's default to 6: nvm alias default 6
Hope this helps others ๐
I'm running into a similar problem reading the node version:
ERROR: Upgrade husky. husky > pre-commit (node v6.9.5) undefined requires at least version 8.6.0 of Node, please upgrade husky > pre-commit hook failed (add --no-verify to bypass)
$nvm list
v6.0.0
v6.7.0
v6.9.5
v6.11.2
v7.5.0
v7.9.0
v8.0.0
v8.11.3
-> v10.8.0
v10.12.0
default -> 10.8.0 (-> v10.8.0)
node -> stable (-> v10.12.0) (default)
stable -> 10.12 (-> v10.12.0) (default)
ENV:
MANPATH=/Users/$myusername/.nvm/versions/node/v10.8.0/share/man:/usr/share/man:/usr/local/share/man:/opt/X11/share/man:/Library/Developer/CommandLineTools/usr/share/man
NVM_CD_FLAGS=
NVM_DIR=/Users/$myusername/.nvm
NVM_BIN=/Users/$myusername/.nvm/versions/node/v10.8.0/bin
NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
package.json
"husky": "^1.3.1",
"lint-staged": "^8.1.0",
I tried rm -rf node_modules package-lock.json && npm i but still getting the same error above.
Does anyone have suggestions on how to fix?
As I don't see this mentioned here: this could be related to using a husky precommit hook alongside nvm. For some odd reason husky doesn't use the version nvm is _currently_ using but instead uses nvm's default version. More about the issue can be found here.
Fix for me was to set nvm's default to 6:
nvm alias default 6Hope this helps others ๐
cool, that's it!!!now it should be nvm alias default 8.6.0
For other devs with the same issue ๐ I kept having this issue even after upgrading lint-staged to 8.1.5 In my case the issue was caused by an old version of husky (when using husky+lint-staged husky will run right before lint-staged).
Using [email protected] with [email protected] fixed my issue
I was experiencing this error with NVM & WebStorm (while everything was fine from the Ubuntu terminal). Seems like there were different Node paths used in both cases, so I ended up configuring ~/.huskyrc as suggested in docs:
# ~/.huskyrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Most helpful comment
For future googlers:
The fix for node v10 is to update
lint-stagedto^7.0.5or