{"record":{"id":"b800326a405b7d2a","repo":"dotnet/aspnetcore","slug":"the-license-file-licensesourcepath-does-not-exi","errorCode":null,"errorMessage":"The license file ${licenseSourcePath} does not exist.","messagePattern":"The license file (.+?) does not exist\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"eng/scripts/npm/pack-workspace.mjs","lineNumber":73,"sourceCode":"  const renames = readJsonSync(resolve(intermediateOutputPath, 'renames.json'));\n  try {\n    createPackages(packagesToPack);\n  } finally {\n    // Restore the package.json files to their \"originals\"\n    for (const [from, to] of renames) {\n      moveSync(from, to, { overwrite: true });\n    }\n  }\n} else {\n  throw new Error(`The action ${action} is not supported.`);\n}\n\n// For each package to pack run npm pack\nfunction createPackages(packagesToPack) {\n  // The repo's LICENSE file lives at the root of the workspace next to package.json.\n  const licenseSourcePath = resolve(dirname(workspacePath), 'LICENSE.txt');\n  if (!existsSync(licenseSourcePath)) {\n    throw new Error(`The license file ${licenseSourcePath} does not exist.`);\n  }\n\n  for (const [packagePath, packageJson] of packagesToPack) {\n    const packageName = packageJson.name;\n    const packageVersion = defaultPackageVersion;\n    const packageDir = dirname(packagePath);\n    const normalizedPackageName = packageName.replace('@', '').replace('/', '-');\n    const packageFileName = `${normalizedPackageName}-${packageVersion}.tgz`;\n    const packageTarball = resolve(packageDir, `${packageFileName}`);\n\n    // Copy the repo's LICENSE file into the package directory so that it ships in the published\n    // package. npm always includes a top-level LICENSE file in the tarball, even when the\n    // package.json \"files\" allowlist is specified, so no changes to \"files\" are required.\n    const licenseDestPath = resolve(packageDir, 'LICENSE.txt');\n    const licenseAlreadyPresent = existsSync(licenseDestPath);\n    if (!licenseAlreadyPresent) {\n      copySync(licenseSourcePath, licenseDestPath);\n    }","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/eng/scripts/npm/pack-workspace.mjs#L55-L91","documentation":"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.","triggerScenarios":"Running --create-packages when resolve(dirname(workspacePath), 'LICENSE.txt') does not exist on disk (pack-workspace.mjs:71-75).","commonSituations":"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).","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."],"exampleFix":"# before - repo root has 'LICENSE' not 'LICENSE.txt'\n# after\nln -s LICENSE LICENSE.txt   # or rename\ncp LICENSE.txt $(dirname $(dirname $workspacePath))/LICENSE.txt","handlingStrategy":"validation","validationCode":"import { resolve, dirname } from 'path';\nimport { existsSync } from 'fs';\nconst licenseSourcePath = resolve(dirname(workspacePath), 'LICENSE.txt');\nif (!existsSync(licenseSourcePath)) {\n    throw new Error(`LICENSE.txt missing at ${licenseSourcePath}`);\n}","typeGuard":"const licensePresent = (ws) => existsSync(resolve(dirname(ws), 'LICENSE.txt'));","tryCatchPattern":null,"preventionTips":["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."],"tags":["nodejs","npm","build","filesystem","licensing"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}