{"record":{"id":"cb38a10be4f3d51f","repo":"dotnet/aspnetcore","slug":"the-default-package-version-was-not-provided-cb38a1","errorCode":null,"errorMessage":"The default package version was not provided.","messagePattern":"The default package version was not provided\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"eng/scripts/npm/update-dependency-versions.mjs","lineNumber":18,"sourceCode":"import path from 'path';\nimport { execSync } from 'child_process';\nimport fs from 'fs-extra';\n\nexport function applyVersions(defaultPackageVersion, workspacePath) {\n  // Get the workspace package.json from the provided path\n  const workspacePackage = fs.readJsonSync(workspacePath);\n\n  // Get the workspace directory\n  const workspaceDir = path.dirname(workspacePath);\n\n  // Validate and throw if the arguments are not provided\n  if (!workspacePath) {\n    throw new Error('The workspace path was not provided.');\n  }\n\n  if (!defaultPackageVersion) {\n    throw new Error('The default package version was not provided.');\n  }\n\n  const packages = workspacePackage.workspaces;\n  const packagesToPack = [];\n  for (const pkg of packages) {\n    const packagePath = path.resolve(workspaceDir, pkg, 'package.json');\n    const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8'));\n    if (!packageJson.private) {\n      packagesToPack.push([packagePath, packageJson]);\n    } else {\n      console.log(`Skipping ${packageJson.name} because it is marked as private.`);\n    }\n  }\n\n  // For each package to be packed, run npm version to apply the version\n  var renames = applyPackageVersion(packagesToPack, defaultPackageVersion);\n\n  updateDependencyVersions(packagesToPack);","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/eng/scripts/npm/update-dependency-versions.mjs#L1-L36","documentation":"applyVersions in update-dependency-versions.mjs requires a non-empty defaultPackageVersion; it is used to stamp every public workspace package's version and to derive dependency version ranges ('>=<version>'). Without it the versioning step cannot run.","triggerScenarios":"Calling applyVersions(defaultPackageVersion, workspacePath) with defaultPackageVersion empty/undefined (update-dependency-versions.mjs:17-19). Unlike the workspacePath guard this check runs after readJsonSync, but defaultPackageVersion is not used until later so the guard is reachable.","commonSituations":"The build property feeding the package version (e.g. $(Version)) was empty when pack-workspace.mjs invoked applyVersions; the CI pipeline did not set a build number.","solutions":["Pass a non-empty default package version into pack-workspace.mjs (argv[4]).","Ensure the MSBuild/CI property supplying the version is populated before the pack target runs.","Add a precondition check in the build target that the version property is set."],"exampleFix":"// before\napplyVersions('', workspacePath);\n// after\napplyVersions('8.0.0', workspacePath);","handlingStrategy":"validation","validationCode":"if (!defaultPackageVersion) {\n    throw new Error('The default package version was not provided.');\n}","typeGuard":"const isVersion = (s) => typeof s === 'string' && /^\\d+\\.\\d+\\.\\d+/.test(s);","tryCatchPattern":null,"preventionTips":["Pass a non-empty version as argv[4] to pack-workspace.mjs.","Ensure the build version property is populated in CI.","Add a precondition check in the MSBuild target."],"tags":["nodejs","npm","build","arguments","versioning"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}