pulumi/pulumi · error
'yarn pack' completed successfully but the packed .tgz file
Error message
'yarn pack' completed successfully but the packed .tgz file was not generated: %w
What it means
'yarn pack' exited successfully but reading the produced .tgz from disk with os.ReadFile failed. Like the pnpm equivalent, this means the tarball path the SDK derived from yarn's output does not exist at the expected location.
Source
Thrown at sdk/nodejs/npm/yarn.go:189
packfile := tmpfile.Name()
// Clean up the tarball after we're done here.
defer func() {
contract.IgnoreClose(tmpfile)
contract.IgnoreError(os.Remove(packfile))
}()
command := exec.CommandContext(ctx, yarn.executable, "pack", "--filename", packfile)
command.Dir = dir
err = yarn.runCmd(command, stderr)
if err != nil {
return nil, err
}
// Read the tarball in as a byte slice.
tarball, err := os.ReadFile(packfile)
if err != nil {
return nil, fmt.Errorf("'yarn pack' completed successfully but the packed .tgz file was not generated: %w", err)
}
return tarball, nil
}
// checkYarnLock checks if there's a file named yarn.lock in pwd.
// This function is used to indicate whether to prefer Yarn over
// other package managers.
func checkYarnLock(pwd string) bool {
_, err := fsutil.Searchup(pwd, "yarn.lock")
return err == nil
}
View on GitHub (pinned to 793f7b2e16)
Solutions
- Run 'yarn pack' manually in the project directory and confirm where the tgz lands
- Use Yarn Classic (v1) whose pack output format matches the SDK's expectations
- Remove custom yarn pack destination settings from .yarnrc.yml/.yarnrc
- Check for plugins/scripts printing extra output that corrupts filename parsing
Example fix
// before (.yarnrc.yml) # custom pack config altering output location // after # removed; tgz generated in project root as expected
Defensive patterns
Strategy: validation
Validate before calling
import fs from 'fs';
if (!fs.existsSync(path.join(dir, 'package.tgz'))) {
throw new Error('yarn pack tarball not found in ' + dir);
} Try / catch
try { await packYarn(dir) } catch (err) { if (String(err).includes('.tgz file was not generated')) { console.error('Run yarn pack manually to see where the tarball lands'); } throw err; } Prevention
- Use Yarn Classic (v1) for projects packed by the SDK
- Do not configure custom pack destinations in .yarnrc/.yarnrc.yml
- Silence plugins/scripts that add extra stdout lines around yarn pack
- Verify the tgz location once locally per CI image
When it happens
Trigger: Calling the yarn pack flow when the parsed pack output filename doesn't resolve to a real file — yarn printed a relative path from a different cwd, or yarn version output format differs from what's parsed.
Common situations: Yarn Berry (v2+) vs Classic output differences; custom yarn config (e.g. enableGlobalCache or pack destination) moving the tarball; extra log lines shifting the parsed filename.
Related errors
- 'pnpm pack' completed successfully but the package .tgz file
- opening log file: %w
- %w: %w
- stat on file %s: %w
- Pack is not supported
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/e3631450742b24a6.
Report an issue: GitHub.