I have lint-staged
installed in a multi-package repository.
The structure is:
|-- package.json
|-- package-one
|-- package.json
|-- javascript
|-- package-two
|-- package.json
|-- javascript
I have the same setup in a different repo on the same machine and the below works with no errors.
I am using lint-staged to run eslint on pre-commit. Each sub-package has a lint
npm script in it.
In the other repository I call lint-staged
on each package without error, however, in this repo when running against a stage file it:
- correctly identifies the staged file
- produces the error
npm could not be found. Try npm install npm.
- if I change the npm script out to simply be
"git add"
then the error isgit could not be found. Try npm install git.
Running which npm
produces the same results in the working and non-working repos.
Running npm install
or any other npm command works when ran directly, just not when ran through lint-staged
.
I am at a loss as to what may be causing this?
"devDependencies": {
"husky": "^2.4.1",
"lint-staged": "^8.2.1",
},
"lint-staged": {
"packages/package-name/**/*.{js,jsx}": [
"npm run --silent lint --prefix packages/package-one"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}