husky: sh: husky: command not found
Context
I’ve setup a node project with husky but when my collegue tries to run npm install
on his Mac he gets the following error :
noa-be@1.0.0 prepare
husky install
sh: husky: command not found
npm ERR! code 127
npm ERR! path /Users/X/Desktop/Workspace/project
npm ERR! command failed
npm ERR! command sh -c husky install
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/X/.npm/_logs/2021-04-12T13_07_25_842Z-debug.log
These are the relevant package.json parts:
{
"scripts": {
"prepare": "husky install"
},
"devDependencies": {
"husky": "^5.2.0",
}
}
I thought this would be enough for husky to be installed when running npm install
, but it’s not. What am I missing?
Thank you!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 9
- Comments: 16 (2 by maintainers)
@ctsstc That didn’t work for me.
The following worked (and is cross platform too):
Everything seems alright on local machine, but when I deploy on Heroku, I get this:
The problem was that
husky
, being installed indevDependencies
, gets stripped away if you setNPM_CONFIG_PRODUCTION=true
.If you use command like
npm ci --omit=dev
you can access those property via$npm_config_omit
. According to value of$npm_config_omit
you can decide to run husky install command or not.Another way:
I seem to have no problems on a new project on heroku with:
v16.13.2
8.1.2
7.0.4
On the other project when I originally commented here I ended up doing:
Note: It was running in a docker container up on AWS.
I ran into this error. Turns out something on my laptop was setting
NODE_ENV="production"
, and husky wasn’t being installed because it’s a dev dependency. SettingNODE_ENV
todevelopment
fixed the problem.