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

Husky prepare script breaking np #742

Open
numfin opened this issue Apr 11, 2024 · 4 comments
Open

Husky prepare script breaking np #742

numfin opened this issue Apr 11, 2024 · 4 comments

Comments

@numfin
Copy link

numfin commented Apr 11, 2024

Description

When husky installed and in package.json prepare: husky install script exists np crashes with

✖ SyntaxError: Unexpected token '>', "
> kirka@5."... is not valid JSON
    at JSON.parse (<anonymous>)
    at Module.getFilesToBePacked (file:///nix/store/zmmxxn34hc1dllqrd7qqid720gqzdjy7-np-9.2.0/lib/node_modules/np/source/npm/util.js:144:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Module.getNewFiles (file:///nix/store/zmmxxn34hc1dllqrd7qqid720gqzdjy7-np-9.2.0/lib/node_modules/np/source/util.js:103:23)
    at async checkNewFilesAndDependencies (file:///nix/store/zmmxxn34hc1dllqrd7qqid720gqzdjy7-np-9.2.0/lib/node_modules/np/source/ui.js:81:19)
    at async ui (file:///nix/store/zmmxxn34hc1dllqrd7qqid720gqzdjy7-np-9.2.0/lib/node_modules/np/source/ui.js:150:30)
    at async file:///nix/store/zmmxxn34hc1dllqrd7qqid720gqzdjy7-np-9.2.0/lib/node_modules/np/source/cli-implementation.js:137:18

This is what is happening in stdout when running np

> [email protected] prepare
> husky install

husky - Git hooks installed
[
  {
    "id": "[email protected]",
    "name": "kirka",
    "version": "5.1.0",
    "size": 138771,
    "unpackedSize": 713895,
    "shasum": "658deca4ed8313011ac886dd7c6bc84c39cab09b",
    "integrity": "sha512-Tb1wefIGsLoYjjGi0sIgp72y/Qoz8IVaq9YbW6L/f7Af3npjKIw51zvUCKoyd/GXvYW78jR88oj5xPr7r+N+MA==",
    "filename": "kirka-5.1.0.tgz",
    "files": [...],
    "entryCount": 694,
    "bundled": []
  }
]

Expected behavior

Should just work

Environment

np - 9.2.0
Node.js - 21.7.1
npm - 10.5.0
Git - 2.42
OS - nixos 23.10 (unstable branch)

@numfin
Copy link
Author

numfin commented Apr 11, 2024

As a workaround i just removed prepare

@voxpelli
Copy link
Contributor

You can fix it by doing:

"prepare": "husky install > /dev/null",

And if you update to version 9 of huskyI also think this issue will go away

@numfin
Copy link
Author

numfin commented Apr 16, 2024

@voxpelli love the idea with output, but it's not crossplatform.
Seems like husky made something with debug output in v9. I'll check later if it really fixes the issue
image

@slhck
Copy link
Contributor

slhck commented Jun 24, 2024

I had a similar issue when migrating from an old project that had:

HUSKY=0 np

in its release script. After migrating to Husky v9, and using husky instead of husky install, I could also remove the HUSKY=0 part and releasing worked fine.

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