nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
107.33k stars 29.47k forks source link

Node.js v23 - NPM publish fails due to "tarball data for file ... seems to be corrupted" #55488

Closed jay-n-h closed 2 hours ago

jay-n-h commented 3 hours ago

Version

23.0.0

Platform

Linux 6.10.12-hardened1-1-hardened #1 SMP PREEMPT_DYNAMIC Wed, 02 Oct 2024 17:47:30 +0000 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Install Node.js v23.0.0 & attempt to pack an NPM package.

How often does it reproduce? Is there a required condition?

No required condition. Always reproducible.

What is the expected behavior? Why is that the expected behavior?

The NPM package should pack successfully.

What do you see instead?

NPM warns about tarball data in the repository directory being null/corrupted, then errors as it cannot find the file to pack.

It seems to be missing the first character of the dist path? I'm not even sure how it knows the .tsbuildinfo file exists when it's apparently looking in the ist instead of dist directory.

npm warn tarball tarball data for file:/home/work/Repositories/example/ (null) seems to be corrupted. Trying again.
npm warn tarball tarball data for file:/home/work/Repositories/example/ (null) seems to be corrupted. Trying again.
npm error code ENOENT
npm error syscall lstat
npm error path /home/work/Repositories/example/ist/.tsbuildinfo
npm error errno -2
npm error enoent ENOENT: no such file or directory, lstat '/home/work/Repositories/example/ist/.tsbuildinfo'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
npm error A complete log of this run can be found in: /home/work/.npm/_logs/2024-10-22T09_39_37_630Z-debug-0.log

My files property in package.json:

"files": [
    "dist",
    "package.json",
    "bun.lockb",
    "README.md"
],

Additional information

Downgrading to Node.js v22.10.0 fixes the issue. NPM now successfully packs the package using the dist directory instead of ist:

npm notice 📦  example@0.1.0
npm notice Tarball Contents
npm notice 135B README.md
npm notice 282.8kB bun.lockb
npm notice 142.9kB dist/.tsbuildinfo
npm notice 2.9MB dist/bin/cli.js
npm notice 6.0MB dist/bin/cli.js.map
npm notice 21.4kB dist/bun.d.ts
npm notice 1.5MB dist/bun.js
npm notice 3.7MB dist/bun.js.map
npm notice 6.1kB package.json
npm notice Tarball Details
npm notice name: example
npm notice version: 0.1.0
npm notice filename: example-0.1.0.tgz
npm notice package size: 3.7 MB
npm notice unpacked size: 14.7 MB
npm notice shasum: ef33d77cc204d62e26e1773ebaad0c99e65cc537
npm notice integrity: sha512-Bl5xasx8pOzXg[...]iFlr/qT3nWjKA==
npm notice total files: 9
npm notice
example-0.1.0.tgz
aladdin-add commented 3 hours ago

Duplicate of https://github.com/nodejs/node/issues/55410