{"record":{"id":"b0dfb04d323ac595","repo":"hcengineering/platform","slug":"invalid-package-specifier-rawpackagespecifier","errorCode":null,"errorMessage":"Invalid package specifier: ${rawPackageSpecifier}","messagePattern":"Invalid package specifier: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/communication/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/communication/common/scripts/install-run.js#L348-L384","documentation":"_parsePackageSpecifier splits a raw \"name[@version]\" string into { name, version }. It throws this error when the resulting package name is empty, meaning the specifier had no usable name portion (e.g. it was empty, or only \"@version\"). The script uses this in install-and-run mode to install and invoke a package's binary without a full checkout.","triggerScenarios":"Calling the install-run script with a package specifier argument that is empty, contains only a version (e.g. \":1.2.3\" separator form producing an empty name), or is otherwise malformed so the parsed name is a falsy string.","commonSituations":"CI pipeline variables like PACKAGE_SPEC being unset or empty and interpolated into the command line; typos such as \"@scoped-pkg@1.2.3\" missing the actual package name; passing a leading separator by mistake.","solutions":["Pass a valid package specifier: the first argument must be the package name, e.g. \"pnpm@8.15.4\" or \"name@version\".","Check the shell variable feeding the specifier for emptiness before invoking the script.","For scoped packages use the correct form \"@scope/name@version\"; do not strip the scope.","Escape the @ in the shell if needed (some shells interpolate) so the name portion survives."],"exampleFix":"// before\nnode install-run.js $EMPTY_VAR@1.0.0\n// after\nnode install-run.js \"${PACKAGE_NAME:?PACKAGE_NAME must be set}@${PACKAGE_VERSION:-latest}\"","handlingStrategy":"validation","validationCode":"const spec = process.argv[2] || '';\nif (!spec || !/^[^@:]+/.test(spec.replace(/^@/, '@scope-ok'))) throw new Error('usage: install-run.js <name[@version]> [-- args]');","typeGuard":null,"tryCatchPattern":"try { runInstall(); } catch (e) { if (/Invalid package specifier/.test(e.message)) { console.error('Bad package specifier:', process.argv[2]); process.exit(2); } throw e; }","preventionTips":["Always pass name and version together, e.g. pnpm@8.15.4","Quote the specifier in shell to protect @ characters","Default CI variables with ${VAR:-fallback} and fail fast with ${VAR:?msg}"],"tags":["npm","argument-validation","scripting"],"backgroundTag":"invalid-package-specifier","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}