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

Fix npm run release (np) error #7570

Merged
merged 2 commits into from Mar 24, 2024
Merged

Fix npm run release (np) error #7570

merged 2 commits into from Mar 24, 2024

Conversation

ybiquitous
Copy link
Member

@ybiquitous ybiquitous commented Mar 24, 2024

Which issue, if any, is this issue related to?

Blocker of #7549

Is there anything in the PR that needs further explanation?

$ npm run release

> stylelint@16.2.1 release
> np --no-release-draft

✖ Error: Failed to parse output of npm pack
    at Module.getFilesToBePacked (file:///Users/masafumi.koba/git/stylelint/stylelint/node_modules/np/source/npm/util.js:147:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Module.getNewFiles (file:///Users/masafumi.koba/git/stylelint/stylelint/node_modules/np/source/util.js:107:27)
    at async checkNewFilesAndDependencies (file:///Users/masafumi.koba/git/stylelint/stylelint/node_modules/np/source/ui.js:82:19)
    at async ui (file:///Users/masafumi.koba/git/stylelint/stylelint/node_modules/np/source/ui.js:138:30)
    at async getOptions (file:///Users/masafumi.koba/git/stylelint/stylelint/node_modules/np/source/cli-implementation.js:146:18)
    at async file:///Users/masafumi.koba/git/stylelint/stylelint/node_modules/np/source/cli-implementation.js:163:45

This error's cause is that npm pack outputs an invalid JSON due to patch-package output.

Instead of the prepare hook, the postinstall hook is not executed with npm pack.

See also:

```
$ npm run release

> stylelint@16.2.1 release
> np --no-release-draft

✖ Error: Failed to parse output of npm pack
    at Module.getFilesToBePacked (file:///Users/masafumi.koba/git/stylelint/stylelint/node_modules/np/source/npm/util.js:147:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Module.getNewFiles (file:///Users/masafumi.koba/git/stylelint/stylelint/node_modules/np/source/util.js:107:27)
    at async checkNewFilesAndDependencies (file:///Users/masafumi.koba/git/stylelint/stylelint/node_modules/np/source/ui.js:82:19)
    at async ui (file:///Users/masafumi.koba/git/stylelint/stylelint/node_modules/np/source/ui.js:138:30)
    at async getOptions (file:///Users/masafumi.koba/git/stylelint/stylelint/node_modules/np/source/cli-implementation.js:146:18)
    at async file:///Users/masafumi.koba/git/stylelint/stylelint/node_modules/np/source/cli-implementation.js:163:45
```

This error's cause is that `npm pack` outputs an invalid JSON due to `patch-package` output.

Instead of the `prepare` hook, the `postinstall` hook is not executed with `npm pack`.

See also:
- https://github.com/ds300/patch-package#set-up
- https://docs.npmjs.com/cli/v10/using-npm/scripts
Copy link

changeset-bot bot commented Mar 24, 2024

⚠️ No Changeset found

Latest commit: 3fb479b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ybiquitous
Copy link
Member Author

Oops. Sadly, the postinstall hook breaks npm i stylelint...

$ npm i /Users/masafumi.koba/git/stylelint/stylelint/*.tgz
npm ERR! code 127
npm ERR! path /Users/masafumi.koba/tmp/foo/node_modules/stylelint
npm ERR! command failed
npm ERR! command sh -c patch-package
npm ERR! sh: patch-package: command not found

@ybiquitous
Copy link
Member Author

ybiquitous commented Mar 24, 2024

The postprepare hook works! (3fb479b)

$ npm i /Users/masafumi.koba/git/stylelint/stylelint/*.tgz

added 120 packages, and audited 121 packages in 12s

25 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

@ybiquitous ybiquitous merged commit 3158781 into main Mar 24, 2024
14 checks passed
@ybiquitous ybiquitous deleted the fix-release-script branch March 24, 2024 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant