{"record":{"id":"fc4fbbe27914956c","repo":"hcengineering/platform","slug":"error-syncing-npmrc-file-e-fc4fbb","errorCode":null,"errorMessage":"Error syncing .npmrc file: ${e}","messagePattern":"Error syncing \\.npmrc file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/server/common/scripts/install-run.js","lineNumber":223,"sourceCode":"            // Ensure the target folder exists\n            if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(targetNpmrcFolder)) {\n                fs__WEBPACK_IMPORTED_MODULE_0__.mkdirSync(targetNpmrcFolder, { recursive: true });\n            }\n            return _copyAndTrimNpmrcFile({\n                sourceNpmrcPath,\n                targetNpmrcPath,\n                logger,\n                ...options\n            });\n        }\n        else if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(targetNpmrcPath)) {\n            // If the source .npmrc doesn't exist and there is one in the target, delete the one in the target\n            logger.info(`Deleting ${targetNpmrcPath}`); // Verbose\n            fs__WEBPACK_IMPORTED_MODULE_0__.unlinkSync(targetNpmrcPath);\n        }\n    }\n    catch (e) {\n        throw new Error(`Error syncing .npmrc file: ${e}`);\n    }\n}\nfunction isVariableSetInNpmrcFile(sourceNpmrcFolder, variableKey, supportEnvVarFallbackSyntax) {\n    const sourceNpmrcPath = `${sourceNpmrcFolder}/.npmrc`;\n    //if .npmrc file does not exist, return false directly\n    if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(sourceNpmrcPath)) {\n        return false;\n    }\n    const trimmedNpmrcFile = _trimNpmrcFile({ sourceNpmrcPath, supportEnvVarFallbackSyntax });\n    const variableKeyRegExp = new RegExp(`^${variableKey}=`, 'm');\n    return trimmedNpmrcFile.match(variableKeyRegExp) !== null;\n}\n//# sourceMappingURL=npmrcUtilities.js.map\n\n/***/ })\n\n/******/ \t});\n/************************************************************************/","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/server/common/scripts/install-run.js#L205-L241","documentation":"syncNpmrc copies the repo's common/config/rush/.npmrc (performing variable substitution) into the target folder. Any failure during copy, read, substitution, or delete is wrapped and rethrown with this message, with the underlying error appended as ${e}.","triggerScenarios":"Source .npmrc missing while target copy fails; filesystem permission errors on read/write/unlink; syncNpmrc called with invalid source/target folder paths; disk full or read-only volume during copy.","commonSituations":"Read-only CI workspaces; repo checkout missing common/config/rush/.npmrc that scripts assume exists; locked .npmrc files on Windows; misconfigured RUSH_TEMP_FOLDER pointing at an unwritable path.","solutions":["Read the underlying ${e} in the message to identify the real cause (ENOENT, EACCES, EPERM)","Ensure common/config/rush/.npmrc exists if your repo expects one, or remove references to it","Check write permissions on the target folder and that the disk is not full/read-only","Run with elevated/correct credentials in CI if the target directory is protected"],"exampleFix":"// before\nsyncNpmrc('/nonexistent/repo/common/config/rush', targetFolder);\n// after\nconst src = '/repo/common/config/rush';\nif (fs.existsSync(`${src}/.npmrc`)) {\n  syncNpmrc(src, targetFolder);\n}","handlingStrategy":"try-catch","validationCode":"const src = `${repoRoot}/common/config/rush/.npmrc`;\nif (fs.existsSync(src) && !fs.statSync(src).isFile()) throw new Error('.npmrc path is not a file');\nfs.accessSync(path.dirname(targetPath), fs.constants.W_OK);","typeGuard":"function canSyncNpmrc(srcFolder, targetFolder) {\n  try { fs.accessSync(srcFolder + '/.npmrc', fs.constants.R_OK); fs.accessSync(targetFolder, fs.constants.W_OK); return true; } catch { return false; }\n}","tryCatchPattern":"try {\n  syncNpmrc(srcFolder, targetFolder);\n} catch (e) {\n  console.error('npmrc sync failed:', e.message); // inspect inner cause\n  process.exit(1);\n}","preventionTips":["Commit common/config/rush/.npmrc if the repo's tooling expects it","Run CI with a writable workspace and HOME set","Check the inner error text (ENOENT/EACCES) before changing configs"],"tags":["npmrc","filesystem","rush"],"backgroundTag":"npmrc-sync-failed","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}