[BUG] prettier: command not found
semseysandor opened this issue · 3 comments
semseysandor commented
What exactly happened?
Steps to reproduce the behavior:
- Run prettier_action:
- name: Check code-style uses: creyD/prettier_action@v4.2 with: dry: true prettier_options: --check **/*.{md,yml}
- Step failed
Installing prettier... Prettifying files... /home/runner/work/_actions/creyD/prettier_action/v4.2/entrypoint.sh: line 74: prettier: command not found Files: Problem running prettier with --check **/*.{md,yml} Error: Process completed with exit code 1.
What should've happened?
Step should succeed or prettier
should run at least.
Note
I've did some debugging:
- it seems
prettier
is not found because$PATH
is off:echo PATH=$PATH PATH=Unknown command: "bin" To see a list of supported npm commands, run: npm help:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
- running
npm help
confirmnpm bin
is not availablenpm <command> Usage: npm install install all the dependencies in your project npm install <foo> add the <foo> dependency to your project npm test run this project's tests npm run <foo> run the script named <foo> npm <command> -h quick help on <command> npm -l display usage info for all commands npm help <term> search for help on <term> npm help npm more involved overview All commands: access, adduser, audit, bugs, cache, ci, completion, config, dedupe, deprecate, diff, dist-tag, docs, doctor, edit, exec, explain, explore, find-dupes, fund, get, help, hook, init, install, install-ci-test, install-test, link, ll, login, logout, ls, org, outdated, owner, pack, ping, pkg, prefix, profile, prune, publish, query, rebuild, repo, restart, root, run-script, search, set, shrinkwrap, star, stars, start, stop, team, test, token, uninstall, unpublish, unstar, update, version, view, whoami Specify configs in the ini-formatted file: /home/runner/.npmrc or on the command line via: npm <command> --key=value More configuration info: npm help config Configuration fields: npm help 7 config npm@9.3.1 /usr/local/lib/node_modules/npm
- check npm version
npm version 9.3.1
- In
npm v9
npm bin
is removed: https://github.blog/changelog/2022-10-24-npm-v9-0-0-released/#%E2%9A%A0%EF%B8%8F-notable-breaking-changes - As $PATH is set by
npm bin
inLine 64 in dc62bca
npm v9
Conclusion
I've executed prettier
with npm exec prettier
and it worked, step succeeded. I'm not sure if that's the way. In that case npm install
might be unneeded as according to the docs npm exec
can fetch packages also. But I'm not too much into Node and npm so I leave this decision for you 😃
david-allison commented
Duplicate of #113
semseysandor commented
A workaround to use this action in your job: pin npm
to version 8
- name: Install npm v8
run: npm i -g npm@8
- name: Check code-style
uses: creyD/prettier_action@v4.2
with:
dry: true
prettier_options: --check **/*.{md,yml}
semseysandor commented
Duplicate of #113
Oh, yes it is. But here are the reasons also, not just a bug report.