{"record":{"id":"2905a1bdc956d963","repo":"hcengineering/platform","slug":"invalid-package-specifier-rawpackagespecifier-2905a1","errorCode":null,"errorMessage":"Invalid package specifier: ${rawPackageSpecifier}","messagePattern":"Invalid package specifier: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/net/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/net/common/scripts/install-run.js#L348-L384","documentation":"_parsePackageSpecifier splits a raw package specifier on the last '@' or ':' separator into a name and version. If the resulting name is empty (specifier starts with a separator, e.g. '@1.2.3' or ':1.2.3'), it throws this error because there is no package name to install.","triggerScenarios":"Calling the install-run script (or resolvePackageSpecifier) with an argument like '@1.2.3', ':latest', or an empty/blank name portion before the version separator.","commonSituations":"Typo in an npm script where the package name was dropped; shell quoting stripped the leading scope name (e.g. '@scope/pkg@1.0.0' mangled by the shell); copy-pasting a version-only string into a bootstrap argument.","solutions":["Pass the full specifier including the name: node install-run.js <name>[@<version>], e.g. 'typescript@4.9.5'.","Quote scoped packages in the shell so the '@' isn't consumed: 'typescript@^4' not @^4.","Check the calling npm script / documentation for a missing package name argument.","If constructing the specifier programmatically, validate it matches /^(?:@[a-z0-9-~][a-z0-9-._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*(@.*)?$/ before invoking."],"exampleFix":"// before\nnode install-run.js @1.2.3           // invalid: name empty\n// after\nnode install-run.js my-package@1.2.3 // valid: name + version","handlingStrategy":"validation","validationCode":"const SPEC = /^(?:@[a-z0-9-~][a-z0-9-._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*(@.*)?$/\nif (!SPEC.test(rawSpecifier) || rawSpecifier.startsWith('@1') || rawSpecifier.startsWith(':')) {\n  throw new Error(`Specifier must be <name>[@<version>], got: ${rawSpecifier}`)\n}","typeGuard":"function isValidPackageSpecifier(s: string): boolean {\n  const [name] = s.split(/[@:]/).filter(Boolean)\n  return typeof name === 'string' && name.length > 0\n}","tryCatchPattern":null,"preventionTips":["Always pass name and version together: name@version, never a bare version.","Quote scoped specifiers in shell scripts so '@' isn't mangled.","Validate specifier format in npm scripts before delegating to bootstrap scripts.","Copy exact specifiers from package.json dependencies rather than retyping them."],"tags":["npm","argument-validation","cli"],"backgroundTag":"invalid-package-specifier","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}