`npx mrm@2 lint-staged` crashes with `Error: .git can't be found (...)`

Viewed 1035

I am trying to set up lint-staged following the instructions from the prettier documentation.
When I run npx mrm@2 lint-staged, I get the following error:

Error: .git can't be found (see https://typicode.github.io/husky/#/?id=custom-directory)
    at Object.install (/home/moritz/.npm/_npx/51762936ba23ccdb/node_modules/husky/lib/index.js:20:15)
    at task (/home/moritz/.npm/_npx/51762936ba23ccdb/node_modules/mrm-task-lint-staged/index.js:214:8)
    at /home/moritz/.npm/_npx/51762936ba23ccdb/node_modules/mrm/src/index.js:170:20

I followed the link from the error and changed the scripts section in package.json accordingly.

 "scripts": {
    "prepare": "cd .. && husky install laravel/.husky"
  }

I still get the same error when running npx mrm@2 lint-staged. What can I do to get lint-staged running?

My project structure:

project
│   .git    
└───laravel
    │   package.json
1 Answers

So I think cd .. should move the cwd to project, which is the root of the git repo.

Simply add pwd && cd .. && husky....
That way, you will know for sure from where you are starting from.

Related