{"record":{"id":"a0e6ef5bcab7936c","repo":"hcengineering/platform","slug":"invalid-package-specifier-rawpackagespecifier-a0e6ef","errorCode":null,"errorMessage":"Invalid package specifier: ${rawPackageSpecifier}","messagePattern":"Invalid package specifier: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/server/common/scripts/install-run.js","lineNumber":366,"sourceCode":"function _parsePackageSpecifier(rawPackageSpecifier) {\n    rawPackageSpecifier = (rawPackageSpecifier || '').trim();\n    const separatorIndex = rawPackageSpecifier.lastIndexOf('@');\n    let name;\n    let version = undefined;\n    if (separatorIndex === 0) {\n        // The specifier starts with a scope and doesn't have a version specified\n        name = rawPackageSpecifier;\n    }\n    else if (separatorIndex === -1) {\n        // The specifier doesn't have a version\n        name = rawPackageSpecifier;\n    }\n    else {\n        name = rawPackageSpecifier.substring(0, separatorIndex);\n        version = rawPackageSpecifier.substring(separatorIndex + 1);\n    }\n    if (!name) {\n        throw new Error(`Invalid package specifier: ${rawPackageSpecifier}`);\n    }\n    return { name, version };\n}\nlet _npmPath = undefined;\n/**\n * Get the absolute path to the npm executable\n */\nfunction getNpmPath() {\n    if (!_npmPath) {\n        try {\n            if (_isWindows()) {\n                // We're on Windows\n                const whereOutput = child_process__WEBPACK_IMPORTED_MODULE_0__.execSync('where npm', { stdio: [] }).toString();\n                const lines = whereOutput.split(os__WEBPACK_IMPORTED_MODULE_2__.EOL).filter((line) => !!line);\n                // take the last result, we are looking for a .cmd command\n                // see https://github.com/microsoft/rushstack/issues/759\n                _npmPath = lines[lines.length - 1];\n            }","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/server/common/scripts/install-run.js#L348-L384","documentation":"_parsePackageSpecifier splits a raw specifier like \"name@version\" (or \"@scope/name@version\") into package name and version. If the computed name part is empty, the specifier is malformed and the script throws this error.","triggerScenarios":"Passing a specifier that starts with the separator (e.g. \"@version\", \".5.0\"); an empty string; a specifier like \"@scope/\" where the name resolves to empty; callers of the runUnmanaged/install-run scripts supplying a bad package argument.","commonSituations":"Typo in install-run-rushp/rushx wrappers' hardcoded package specifiers after edits; shell variable expansion yielding an empty package name in custom scripts; hand-written invocations like install-run.js \"@1.2.3\".","solutions":["Pass a well-formed specifier: <name>[@<version>], e.g. \"pnpm@7.28.0\" or \"@scope/pkg@1.0.0\"","Check the RUSH_PKG_NAME/RUSH_PKG_VERSION or hardcoded constants in install-run-rush*.js wrappers are non-empty","Quote arguments in shell scripts so variables do not expand to empty and get dropped"],"exampleFix":"// before\nrunInstallRunInPackage('');\nrunInstallRunInPackage('@1.2.3');\n// after\nrunInstallRunInPackage('typescript@5.4.5');\nrunInstallRunInPackage('@rushstack/heft@0.60.0');","handlingStrategy":"validation","validationCode":"function isValidSpecifier(s) {\n  return typeof s === 'string' && s.length > 0 && /^(@[a-z0-9-~][a-z0-9-._~]*\\/)?.[a-zA-Z0-9-._~]+(@[0-9a-zA-Z.+\\-~]+)?$/.test(s);\n}\nif (!isValidSpecifier(raw)) throw new Error(`Bad specifier: ${raw}`);","typeGuard":"function isPackageSpecifier(v) {\n  return typeof v === 'string' && v.trim().length > 0 && !v.startsWith('@ver') && v.split('@').filter(Boolean).length >= 1;\n}","tryCatchPattern":"try {\n  runInstallRunInPackage(spec);\n} catch (e) {\n  if (String(e).startsWith('Invalid package specifier')) {\n    console.error(`Use <name>[@<version>] form, e.g. pnpm@8.15.4; got: ${spec}`);\n  } else throw e;\n}","preventionTips":["Quote package specifiers in shell scripts so variables never expand empty","Keep the package name/version constants in install-run-rush* wrappers valid","Validate user-supplied package strings before passing to Rush scripts"],"tags":["package-specifier","parsing","rush"],"backgroundTag":"invalid-package-specifier","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}