dotnet/aspnetcore · error · Error
The license file ${licenseSourcePath} does not exist.
Error message
The license file ${licenseSourcePath} does not exist. What it means
In createPackages the script resolves LICENSE.txt in the directory above the workspace (the repo root) and requires it to exist so it can be copied into each packed tarball. npm always includes a top-level LICENSE file, so its presence is mandatory for the produced packages.
Source
Thrown at eng/scripts/npm/pack-workspace.mjs:73
const renames = readJsonSync(resolve(intermediateOutputPath, 'renames.json'));
try {
createPackages(packagesToPack);
} finally {
// Restore the package.json files to their "originals"
for (const [from, to] of renames) {
moveSync(from, to, { overwrite: true });
}
}
} else {
throw new Error(`The action ${action} is not supported.`);
}
// For each package to pack run npm pack
function createPackages(packagesToPack) {
// The repo's LICENSE file lives at the root of the workspace next to package.json.
const licenseSourcePath = resolve(dirname(workspacePath), 'LICENSE.txt');
if (!existsSync(licenseSourcePath)) {
throw new Error(`The license file ${licenseSourcePath} does not exist.`);
}
for (const [packagePath, packageJson] of packagesToPack) {
const packageName = packageJson.name;
const packageVersion = defaultPackageVersion;
const packageDir = dirname(packagePath);
const normalizedPackageName = packageName.replace('@', '').replace('/', '-');
const packageFileName = `${normalizedPackageName}-${packageVersion}.tgz`;
const packageTarball = resolve(packageDir, `${packageFileName}`);
// Copy the repo's LICENSE file into the package directory so that it ships in the published
// package. npm always includes a top-level LICENSE file in the tarball, even when the
// package.json "files" allowlist is specified, so no changes to "files" are required.
const licenseDestPath = resolve(packageDir, 'LICENSE.txt');
const licenseAlreadyPresent = existsSync(licenseDestPath);
if (!licenseAlreadyPresent) {
copySync(licenseSourcePath, licenseDestPath);
}View on GitHub (pinned to 3600ca084e)
Solutions
- Ensure LICENSE.txt exists at the repo root (sibling of the root package.json).
- Confirm workspacePath points at a package whose grandparent directory is the repo root.
- If the repo uses a differently named license file, restore/symlink it to LICENSE.txt before packing.
Example fix
# before - repo root has 'LICENSE' not 'LICENSE.txt' # after ln -s LICENSE LICENSE.txt # or rename cp LICENSE.txt $(dirname $(dirname $workspacePath))/LICENSE.txt
Defensive patterns
Strategy: validation
Validate before calling
import { resolve, dirname } from 'path';
import { existsSync } from 'fs';
const licenseSourcePath = resolve(dirname(workspacePath), 'LICENSE.txt');
if (!existsSync(licenseSourcePath)) {
throw new Error(`LICENSE.txt missing at ${licenseSourcePath}`);
} Type guard
const licensePresent = (ws) => existsSync(resolve(dirname(ws), 'LICENSE.txt'));
Prevention
- Keep LICENSE.txt at the repo root.
- Ensure workspacePath's grandparent is the repo root.
- Symlink/rename if the repo uses a different license filename.
When it happens
Trigger: Running --create-packages when resolve(dirname(workspacePath), 'LICENSE.txt') does not exist on disk (pack-workspace.mjs:71-75).
Common situations: Running the script from a shallow checkout that lacks the repo-root LICENSE.txt; workspacePath pointing at a package whose dirname's parent does not contain LICENSE.txt; the file was renamed (e.g. to LICENSE not LICENSE.txt).
Related errors
- The package output path ${packageOutputPath} does not exist.
- The workspace path was not provided.
- The default package version was not provided.
- The package output path was not provided.
- The intermediate output path was not provided.
AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11).
Data as JSON: /api/errors/b800326a405b7d2a.
Report an issue: GitHub.