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

Not working with npx & husky pre-commit hook #162

Open
archcorsair opened this issue Mar 22, 2023 · 2 comments
Open

Not working with npx & husky pre-commit hook #162

archcorsair opened this issue Mar 22, 2023 · 2 comments

Comments

@archcorsair
Copy link

Summary

I am able to get this working with pretty-quick being installed as a dev dependency but I cannot get it to run just from using npx. This includes this command: npx -p prettier@latest -p pretty-quick pretty-quick results in the same error below.

Output npx pretty-quick

node:internal/modules/cjs/loader:959
  throw err;
  ^

Error: Cannot find module 'prettier'
Require stack:
- /Users/nxc/.npm/_npx/15f9efe159c89f49/node_modules/pretty-quick/dist/processFiles.js
- /Users/nxc/.npm/_npx/15f9efe159c89f49/node_modules/pretty-quick/dist/index.js
- /Users/nxc/.npm/_npx/15f9efe159c89f49/node_modules/pretty-quick/bin/pretty-quick.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/nxc/.npm/_npx/15f9efe159c89f49/node_modules/pretty-quick/dist/processFiles.js:10:40)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/nxc/.npm/_npx/15f9efe159c89f49/node_modules/pretty-quick/dist/processFiles.js',
    '/Users/nxc/.npm/_npx/15f9efe159c89f49/node_modules/pretty-quick/dist/index.js',
    '/Users/nxc/.npm/_npx/15f9efe159c89f49/node_modules/pretty-quick/bin/pretty-quick.js'
  ]
}
@JounQin
Copy link
Member

JounQin commented Jan 16, 2024

A minimal but runnable online reproduction is required.

@program247365
Copy link

This command worked for me:

npx -p prettier@^2 -p pretty-quick pretty-quick --staged

Running this did not:

npx pretty-quick --staged

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

3 participants