'lint-staged' is not recognized as an internal or external command, operable program or batch file. (Windows)
See original GitHub issueDescription
When using cmd.exe or Visual Studio Code in Windows I get the error “‘lint-staged’ is not recognized as an internal or external command, operable program or batch file.” when I attempt to commit my changes. Essentially the pre-commit fails because of this. This error does not occur in the Windows Subsystem for Linux command prompt.
Steps to reproduce
- Insure you are on a Windows machine with git installed.
- Create a project that uses lint-staged
- Make a change to your repo.
- Using Visual Studio Code or simply cmd.exe, attempt to commit your changes.
- You should see the error mentioned above in the console.
Debug Logs
expand to view
> git commit --quiet --allow-empty-message --file -
> git show :package.json
husky > npm run -s precommit (node v8.10.0)
'lint-staged' is not recognized as an internal or external command,
operable program or batch file.
husky > pre-commit hook failed (add --no-verify to bypass)
> git config --get-all user.name
> git config --get-all user.email
Environment
- OS: Windows 10
- Node.js: v8.10.0
lint-staged
: v7.0.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:20 (1 by maintainers)
Top Results From Across the Web
lint-staged not running on precommit - Stack Overflow
this script will create a .husky folder to your working directory and adds pre-commit file to it with script npm run lint-fix to...
Read more >lint-staged - npm
Run linters against staged git files and don't let slip into your code base! npm install --save-dev lint-staged # requires further setup.
Read more >'lint-staged' is not recognized as an internal or external ...
'lint-staged' is not recognized as an internal or external command, operable program or batch file. (Windows)
Read more >How to Fix “not recognized as an internal or external ...
The second possible reason the “not recognized as an internal or external command” occurs is that you don't have the appropriate program ......
Read more >lint-staged tslint
'lint-staged' is not recognized as an internal or external command, operable program or batch file. > git commit --quiet --allow-empty-message --file ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
tl;dr: You might run into this problem on WSL if you’re using an IDE or other tool that is making your commit for you, and that tool uses a Windows version of node/npm.
I’m not sure if this solution will be relevant for some of the other folks in this thread, but I figured out what was going on for me. I noted in my previous comment that I’m using WSL, and that I’m able to commit from the command line, but that Webstorm gives the
'lint-staged' is not recognized
error.I realized it’s because my command line uses a version of node and npm installed on the Windows side of things, not installed in the WSL directories. I ran
npm install -g lint-staged
in my windows terminal (not in ConEmu, which I have set up to use Fish on WSL). Then I was able to commit normally from Webstorm.I’m still not completely sure why I needed to install
lint-staged
globally - I thought that npm scripts would search the localnode_modules
directory when resolving commands. Anyway, it works fine now.Thanks @oturpe for the recap - especially workaround no.3. I added
npx
to every command in husky config (exceptgit
related of course). So instead ofi did:
Worked like a charm!