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

np with npm 10.5.1: Failed to parse output of npm pack #740

Closed
karlhorky opened this issue Apr 3, 2024 · 6 comments · Fixed by #743 or #744
Closed

np with npm 10.5.1: Failed to parse output of npm pack #740

karlhorky opened this issue Apr 3, 2024 · 6 comments · Fixed by #743 or #744

Comments

@karlhorky
Copy link
Contributor

Description

Using [email protected] (latest as of 3 Apr 2024), the following error message is thrown during publish:

➜  preflight git:(main) np --yolo

✖ Error: Failed to parse output of npm pack
    at Module.getFilesToBePacked (file:///Users/k/Library/pnpm/global/5/.pnpm/[email protected]/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/k/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/np/source/util.js:107:27)
    at async checkNewFilesAndDependencies (file:///Users/k/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/np/source/ui.js:82:19)
    at async ui (file:///Users/k/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/np/source/ui.js:138:30)
    at async getOptions (file:///Users/k/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/np/source/cli-implementation.js:146:18)
    at async file:///Users/k/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/np/source/cli-implementation.js:163:45

This is probably because npm pack with the flags that np uses also returns output with npm v10:

npm pack --dry-run --json --silent

> @upleveled/[email protected] build /Users/k/p/preflight
> tsdx build --format esm --target node --tsconfig tsconfig.src.json "--silent"

✓ Building modules 585 ms
[
  {
    "id": "@upleveled/[email protected]",
    ...

Steps to reproduce

  1. Use a package with a prepare script that generates output
  2. Use npm v10.5.1
  3. Run np

Expected behavior

Package should be published, like it is with npm v9

Environment

np - 10.0.2
Node.js - 20.12.0
npm - 10.5.1
Git - 2.39.2
OS - macOS Sonoma 14.4.1 (23E224)

@karlhorky
Copy link
Contributor Author

@transitive-bullshit @sindresorhus Thanks for the #743 PR and review 🙌

Will this be released in the next minor or patch version of np? eg:

@sindresorhus
Copy link
Owner

https://github.com/sindresorhus/np/releases/tag/v10.0.4

@karlhorky
Copy link
Contributor Author

karlhorky commented Apr 17, 2024

Thanks!

Tried to confirm the fix with [email protected] + [email protected], but still encountering the error:

➜  preflight git:(main) pnpm i -g [email protected]
Packages: +1 -1
+-
Progress: resolved 510, reused 509, downloaded 1, added 1, done

/Users/k/Library/pnpm/global/5:
- np 10.0.3
+ np 10.0.4

Done in 6.4s
➜  preflight git:(main) npm --version
10.5.2
➜  preflight git:(main) np --version
10.0.4
➜  preflight git:(main) np

✖ Error: Failed to parse output of npm pack
    at Module.getFilesToBePacked (file:///Users/k/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/np/source/npm/util.js:149:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Module.getNewFiles (file:///Users/k/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/np/source/util.js:107:27)
    at async checkNewFilesAndDependencies (file:///Users/k/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/np/source/ui.js:82:19)
    at async ui (file:///Users/k/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/np/source/ui.js:138:30)
    at async getOptions (file:///Users/k/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/np/source/cli-implementation.js:146:18)
    at async file:///Users/k/Library/pnpm/global/5/.pnpm/[email protected]/node_modules/np/source/cli-implementation.js:163:45

More context (output of npm pack):

➜  preflight git:(main) npm pack

> @upleveled/[email protected] prepare
> pnpm build


> @upleveled/[email protected] build /Users/k/p/preflight
> tsdx build --format esm --target node --tsconfig tsconfig.src.json

✓ Building modules 507 ms
npm notice
npm notice 📦  @upleveled/[email protected]
npm notice === Tarball Contents ===
npm notice 1.1kB  LICENSE
npm notice 1.3kB  README.md
npm notice 56B    bin/preflight.js
npm notice 128B   dist/checks/allChangesCommittedToGit.d.ts
npm notice 93B    dist/checks/eslint.d.ts
npm notice 126B   dist/checks/eslintConfigIsValid.d.ts
npm notice 142B   dist/checks/linkOnGithubAbout.d.ts
npm notice 136B   dist/checks/nodeModulesIgnoredFromGit.d.ts
npm notice 132B   dist/checks/noDependencyProblems/nextJsProjectHasSharpInstalled.d.ts
npm notice 131B   dist/checks/noDependencyProblems/noDependenciesWithoutTypes.d.ts
npm notice 128B   dist/checks/noDependencyProblems/noUnusedDependencies.d.ts
npm notice 143B   dist/checks/noExtraneousFilesCommittedToGit.d.ts
npm notice 126B   dist/checks/noSecretsCommittedToGit.d.ts
npm notice 127B   dist/checks/preflightIsLatestVersion.d.ts
npm notice 97B    dist/checks/prettier.d.ts
npm notice 146B   dist/checks/projectFolderNameMatchesCorrectFormat.d.ts
npm notice 164B   dist/checks/stylelint.d.ts
npm notice 132B   dist/checks/stylelintConfigIsValid.d.ts
npm notice 125B   dist/checks/useSinglePackageManager.d.ts
npm notice 11B    dist/index.d.ts
npm notice 27.1kB dist/preflight.esm.js
npm notice 51.7kB dist/preflight.esm.js.map
npm notice 76B    dist/types/CtxParam.d.ts
npm notice 156B   dist/types/TaskParam.d.ts
npm notice 65B    dist/util/commandExample.d.ts
npm notice 66B    dist/util/crossPlatform.d.ts
npm notice 53B    dist/util/drone.d.ts
npm notice 1.3kB  dist/util/packageJson.d.ts
npm notice 47B    dist/util/preflightBinPath.d.ts
npm notice 51B    dist/util/randomUserAgent.d.ts
npm notice 2.9kB  package.json
npm notice 1.2kB  src/checks/allChangesCommittedToGit.ts
npm notice 1.8kB  src/checks/eslint.ts
npm notice 2.8kB  src/checks/eslintConfigIsValid.ts
npm notice 1.6kB  src/checks/linkOnGithubAbout.ts
npm notice 997B   src/checks/nodeModulesIgnoredFromGit.ts
npm notice 636B   src/checks/noDependencyProblems/nextJsProjectHasSharpInstalled.ts
npm notice 3.9kB  src/checks/noDependencyProblems/noDependenciesWithoutTypes.ts
npm notice 3.2kB  src/checks/noDependencyProblems/noUnusedDependencies.ts
npm notice 743B   src/checks/noExtraneousFilesCommittedToGit.ts
npm notice 1.0kB  src/checks/noSecretsCommittedToGit.ts
npm notice 851B   src/checks/preflightIsLatestVersion.ts
npm notice 901B   src/checks/prettier.ts
npm notice 963B   src/checks/projectFolderNameMatchesCorrectFormat.ts
npm notice 1.8kB  src/checks/stylelint.ts
npm notice 3.0kB  src/checks/stylelintConfigIsValid.ts
npm notice 949B   src/checks/useSinglePackageManager.ts
npm notice 3.6kB  src/index.ts
npm notice 77B    src/types/CtxParam.ts
npm notice 165B   src/types/TaskParam.ts
npm notice 90B    src/types/top-user-agents.d.ts
npm notice 345B   src/util/commandExample.ts
npm notice 243B   src/util/crossPlatform.ts
npm notice 203B   src/util/drone.ts
npm notice 1.4kB  src/util/packageJson.ts
npm notice 247B   src/util/preflightBinPath.ts
npm notice 191B   src/util/randomUserAgent.ts
npm notice === Tarball Details ===
npm notice name:          @upleveled/preflight
npm notice version:       7.0.3
npm notice filename:      upleveled-preflight-7.0.3.tgz
npm notice package size:  33.0 kB
npm notice unpacked size: 120.9 kB
npm notice shasum:        4873f8be9307c7581b9909e6c5aee2deeaae1cbf
npm notice integrity:     sha512-MIomTY1lT9ufk[...]oPAJzQkN6okhA==
npm notice total files:   57
npm notice
upleveled-preflight-7.0.3.tgz

This is tsdx, so it shows an animated spinner + progress bar thing during build too:

Screenshot 2024-04-17 at 18 01 34

Or maybe I'm doing something wrong?

cc @transitive-bullshit

@karlhorky
Copy link
Contributor Author

I guess an alternative workaround implementation in np could potentially use npm pack --foreground-scripts=false

@karlhorky
Copy link
Contributor Author

Eg. maybe something like this PR:

@karlhorky
Copy link
Contributor Author

@sindresorhus thanks for the review and merge of my PR and publish of [email protected] 👍

I can confirm that [email protected] is no longer failing with npm@^10 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants