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 init fails when package.json does not have scripts #1342

Closed
1 task done
julien-f opened this issue Jan 25, 2024 · 1 comment
Closed
1 task done

husky init fails when package.json does not have scripts #1342

julien-f opened this issue Jan 25, 2024 · 1 comment

Comments

@julien-f
Copy link
Contributor

Troubleshoot

If you're migrating from husky 4, see:
https://typicode.github.io/husky/migrating-from-v4.html

Context

The error:

$ echo '{}' > package.json
$ npx husky init
Need to install the following packages:
husky@9.0.2
Ok to proceed? (y) y
file:///home/julien.fontanet/.npm/_npx/0d92fdd791cc1044/node_modules/husky/bin.js:10
  d.scripts.prepare = 'husky'
                    ^

TypeError: Cannot set properties of undefined (setting 'prepare')
    at file:///home/julien.fontanet/.npm/_npx/0d92fdd791cc1044/node_modules/husky/bin.js:10:21
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:336:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:106:12)

Node.js v18.19.0
@typicode
Copy link
Owner

Thanks for the report. Fixed by #1338

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

2 participants