{"record":{"id":"ca72bac067374c96","repo":"hcengineering/platform","slug":"invalid-package-specifier-rawpackagespecifier-ca72ba","errorCode":null,"errorMessage":"Invalid package specifier: ${rawPackageSpecifier}","messagePattern":"Invalid package specifier: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/utils/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/utils/common/scripts/install-run.js#L348-L384","documentation":"_parsePackageSpecifier splits a raw specifier like 'name@version' into { name, version }. If the resulting name portion is empty — e.g. the specifier starts with '@' or '@' with no name before a separator — it throws 'Invalid package specifier: <raw>'.","triggerScenarios":"Calling install-run.js / runPackage with a package specifier that has no name portion: '@1.2.3', '@scope/', or an empty string after parsing the '@' separator.","commonSituations":"Hand-typed CLI argument with a leading '@' and missing package name; shell quoting dropping part of the argument; script variable interpolating to '@version'.","solutions":["Pass a full specifier including the package name: 'lodash@4.17.21' or '@scope/pkg@1.0.0'","Check shell quoting so the '@' segment isn't split or lost","Validate the specifier in the calling script before invoking install-run.js"],"exampleFix":"// before\nnode install-run.js run @1.2.3\n// after\nnode install-run.js run my-package@1.2.3","handlingStrategy":"validation","validationCode":"function assertPackageSpecifier(raw) {\n  if (typeof raw !== 'string' || raw.length === 0) {\n    throw new Error(`package specifier required, got: ${JSON.stringify(raw)}`)\n  }\n  const idx = raw.indexOf('@', raw[0] === '@' ? 1 : 0)\n  const name = idx > 0 ? raw.substring(0, idx) : (raw[0] === '@' ? raw : raw.split('@')[0])\n  if (!name) throw new Error(`invalid package specifier: ${raw}`)\n}","typeGuard":"function isValidPackageSpecifier(raw) {\n  return typeof raw === 'string' &&\n    (/^@[^@/]+\\/[^@]+(@.+)?$/.test(raw) || /^[^@]+(@.+)?$/.test(raw))\n}","tryCatchPattern":"try {\n  runPackage(specifier, ...)\n} catch (e) {\n  if (String(e.message).startsWith('Invalid package specifier:')) {\n    console.error(`'${specifier}' must be 'name[@version]' or '@scope/name[@version]'`)\n    process.exit(1)\n  }\n  throw e\n}","preventionTips":["Quote package specifiers in shell scripts to avoid '@' splitting issues","Use a specifier regex validator before passing user input to install-run.js","Prefer fully-qualified 'name@version' specifiers in automation"],"tags":["npm","parsing","cli"],"backgroundTag":"invalid-package-specifier","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}