-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lint-staged command is not found #618
Comments
Hi fayfang,
|
yeah, but I am confused that why the cmd in ./node_module/.bin can not be used when git commit. not only the lint-staged ,but also all the cmd in ./node_module/.bin can not be used. |
Can you show the error message? |
It may be worth testing with Husky v4. As the reason why |
Is this an intentional change in behavior from v3? I'm running into the same issue. |
Update: Adding |
That's the right fix, for husky v5 and v4, locally installed commands need to be run via the package manager. Alternatively, this will work too: // .husky/pre-commit (v5) or .huskyrc (v4)
npm run pre-commit // package.json
{
"scripts": {
"pre-commit": "lint-staged"
}
} |
If the husky hook is not being called, try to install version 4: npm install husky@4 --save-dev |
Electron v12 introduced a breaking change, so we need to set contextIsolation to false for our app to continue to work. Also update husky to fix husky-run command not found, as seen in typicode/husky/issues/854, and lint-staged not found, in typicode/husky/issues/618 and prettier config change https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21
To follow @typicode's message:
If you change your
|
- Run linters against staged git files and don't let 💩 slip into your code base! Linting makes more sense when run before committing your code. By doing so you can ensure no errors go into the repository and enforce code style. But running a lint process on a whole project is slow, and linting results can be irrelevant. Ultimately you only want to lint files that will be committed. Steps: - Install the npm package `lint-staged` with the command: `npm install lint-staged --save-dev` - Add the configuration to the `.lintstagedrc` file. This will run `npm run lint` on the files that have been modified and are being prepared for upload. - Change the `npm run lint` to `npx lint-staged` on the `pre-commit` file. Husky instead of directly running `npm run lint` will run `lint-staged` so you don't have to check all the files in the repository at once. References: - https://www.youtube.com/watch?v=jNxDNoYEGVU - https://dev.to/truemark/run-eslint-on-git-commit-with-husky-and-lint-staged-in-reactjs-4oeb - typicode/husky#618 - https://www.npmjs.com/package/lint-staged#Configuration
Adding |
Also this worked for me. |
If you are also desperately trying to fix ".husky/pre-commit: line 4: lint-staged: command not found", add "npx lint-staged" to your pre-commit file. Read more about the solution here: https://storksnestblog.wordpress.com/2023/01/11/fixing-husky-lint-staged-command-not-found-error/ |
I should've read your comment earlier :D |
…ook from Intellij commit GUI. Solution found here typicode/husky#618 (comment)
Steps: - Install the `lint-staged` package using the command: `npm install lint-staged -D` - Make a clean installation: 1. Delete the `node_modules` folder and the `package-lock.json` file. 2. Reinstall the packages with the command: `npm install --ignore-scripts` Reason: - Sometimes, when saving a file, errors are not corrected automatically. That is why I add the `lint-staged` package, to make sure there are no formatting errors before uploading the changes to the remote repository. References: - https://www.youtube.com/watch?v=jNxDNoYEGVU - https://dev.to/truemark/run-eslint-on-git-commit-with-husky-and-lint-staged-in-reactjs-4oeb - typicode/husky#618 - https://www.npmjs.com/package/lint-staged#Configuration
Description: - Run linters against staged git files and don't let 💩 slip into your code base! Linting makes more sense when run before committing your code. By doing so you can ensure no errors go into the repository and enforce code style. But running a lint process on a whole project is slow, and linting results can be irrelevant. Ultimately you only want to lint files that will be committed. Steps: - Run the following command to create the `.husky/pre-commit` file: `npx husky add .husky/pre-commit "npx lint-staged"` Husky instead of directly running `npm run lint` will run `lint-staged` so you don't have to check all the files in the repository at once. - Create the `.lintstagedrc` file and add the configuration to run the `npm run lint` command when any file changes. This will run `npm run lint` on files that have been modified and are being prepared for upload. - Create the `.huskyrc` file and add the configuration to use `lint-staged` when `husky` runs the `pre-commit` hook. With this setting the `lint` command is executed before committing changes. So the project files are always formatted with `prettier`, `stylelint` and `eslint`. References: - https://www.youtube.com/watch?v=jNxDNoYEGVU - https://dev.to/truemark/run-eslint-on-git-commit-with-husky-and-lint-staged-in-reactjs-4oeb - typicode/husky#618 - https://www.npmjs.com/package/lint-staged#Configuration
when I use package.json below, the output is 'lint-staged command is not found'
when I use the npm command like this, It work
How can I fix it up?
OS: windows
terminal: git bash
git version: 2.17
The text was updated successfully, but these errors were encountered: