I was using node 7.10.0
and had the same problem. I found an issue logged on it's repo where mmoutenot posted an interesting reply which got me thinking so I looked into it further and found the solution!
Husky assumes that everyone uses nvm to manage node versions and looks for it under NVM_DIR(set to $HOME/.nvm
) or if installed with brew BREW_NVM_DIR(set to /usr/local/opt/nvm
)
if either path exists than it loads the node version using load_nvm.
When I initially started working with Node I did use nvm but later on moved on to using n and didn't realise that .nvm had not been cleaned up under the home directory so it was pointing to an older version of node(0.12.7
) - which caused above mentioned error.
If you are still using nvm to manage node versions please ensure that you update to node version that supports ES6 features(const
in this case).
If you are not using nvm than ensure that the nvm is not available on above mentioned paths. Husky ends up using the current version in that case (i.e. 6.10.0
in your case)
Alternatively you can try the solution that mmoutenot mentioned on husky issue
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…