Skip to content
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

npx commands not working #1066

Closed
9jaGuy opened this issue Oct 24, 2021 · 13 comments
Closed

npx commands not working #1066

9jaGuy opened this issue Oct 24, 2021 · 13 comments

Comments

@9jaGuy
Copy link

9jaGuy commented Oct 24, 2021

npx tsc
npx lint-staged
npm run prettier:check

The above is my pre-commit and it was working fine, but just started failing.
After hours of debugging, the only time I can get it to work is to remove npx and do npm run tsc

OS: Windows

@typicode
Copy link
Owner

Hi @9jaboy,

What kind of error are you getting with npx? Could you paste the error?

@9jaGuy
Copy link
Author

9jaGuy commented Oct 25, 2021

husky - pre-commit hook exited with code 1

@9jaGuy 9jaGuy changed the title [Windows] npx commands not working npx commands not working Oct 25, 2021
@PaulRBerg
Copy link

PaulRBerg commented Oct 25, 2021

This is happening for me as well:

$ git commit -e
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 2s 249ms
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed in 1s 469ms
➤ YN0000: Done in 3s 786ms

husky - pre-commit hook exited with code 1 (error)

There's no debug information beside the error message above. I didn't upgrade my OS or change to my Husky setup recently, so I suppose this is a backend issue.

Environment:

  • macOS@11.6
  • husky@7.0.2
  • lint-staged@11.2.3
  • git@2.31.1
  • yarn@3.0.2

@typicode
Copy link
Owner

Thanks for the details.
Hmm not sure what can be done on husky's side.

Working on my side env:

  • Linux
  • lint-staged@11.2.4
  • npx@8
/t/foo main• ❱ g ci -m test
✔ Preparing...
✔ Running tasks...
✔ Applying modifications...
✔ Cleaning up...
[main 7e66935] test
 1 file changed, 3 insertions(+)
# ...
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged

@PaulRBerg
Copy link

PaulRBerg commented Oct 25, 2021

I am using yarn v3.0.2 - could that be the cause? You should be able to replicate the problem if you copy my solidity-template and attempt to make any commit.

One of my users has already opened a discussion about this: PaulRBerg/hardhat-template#74.

@typicode
Copy link
Owner

typicode commented Oct 25, 2021

Thanks, I’ll give it a try. If you use yarn instead of npx to run commands like lint-staged does it work better?

@PaulRBerg
Copy link

It's just more consistent to use yarn everywhere.

@typicode
Copy link
Owner

It's just more consistent to use yarn everywhere.

Agree. Misread, thought you were using npx with yarn install.

@typicode
Copy link
Owner

Can't seem to reproduce, tried on PowerShell Windows with npx and yarn.

PS D:\tmp\husky-npx> git commit -m test
‼ Skipping backup because there’s no initial commit yet.

[STARTED] Preparing...
[SUCCESS] Preparing...
[STARTED] Running tasks...
[STARTED] Running tasks for *
[STARTED] echo hello
[SUCCESS] echo hello
[SUCCESS] Running tasks for *
[SUCCESS] Running tasks...
[STARTED] Applying modifications...
[SUCCESS] Applying modifications...
[master (root-commit) 767bf85] test
 1 file changed, 19 insertions(+)
 create mode 100644 package.json

PS D:\tmp\husky-npx> cat .\.husky\pre-commit
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
PS D:\tmp\husky-yarn> git commit -m test
[STARTED] Preparing...
[SUCCESS] Preparing...
[STARTED] Running tasks...
[STARTED] Running tasks for *
[STARTED] echo hello
[SUCCESS] echo hello
[SUCCESS] Running tasks for *
[SUCCESS] Running tasks...
[STARTED] Applying modifications...
[SUCCESS] Applying modifications...
[STARTED] Cleaning up...
[SUCCESS] Cleaning up...
[master 978af29] test
 1 file changed, 642 insertions(+)
 create mode 100644 yarn.lock

PS D:\tmp\husky-yarn> cat .\.husky\pre-commit
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged

You can take husky's code from the equation by commenting the following line in .husky/pre-commit:

#!/bin/sh
# . "$(dirname "$0")/_/husky.sh"

npx lint-staged

It may help with debugging. Let me know if you still have the issue without this line.

@typicode
Copy link
Owner

typicode commented Oct 26, 2021

I may have found the cause yarn dlx lint-staged exits with code 1 (that's why the hook fails). You should try using yarn lint-staged instead.

@chillyistkult
Copy link

The issue is related to lint-staged/lint-staged#1032

@PaulRBerg
Copy link

The issue is related to okonet/lint-staged#1032

Indeed! As @aaronadamsCA explained here, this issue was caused by lint-staged v11.2.4. Upgrading to v11.2.5 fixes it!

Thanks for taking a look at this, @typicode! @9jaboy can you upgrade your dependencies and see if it works now?

@9jaGuy
Copy link
Author

9jaGuy commented Oct 26, 2021

I can confirm it works. I guess I could've made the connection :)

@9jaGuy 9jaGuy closed this as completed Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants