hcengineering/platform · error
Error syncing .npmrc file: ${e}
Error message
Error syncing .npmrc file: ${e} What it means
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}.
Source
Thrown at foundations/server/common/scripts/install-run.js:223
// Ensure the target folder exists
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(targetNpmrcFolder)) {
fs__WEBPACK_IMPORTED_MODULE_0__.mkdirSync(targetNpmrcFolder, { recursive: true });
}
return _copyAndTrimNpmrcFile({
sourceNpmrcPath,
targetNpmrcPath,
logger,
...options
});
}
else if (fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(targetNpmrcPath)) {
// If the source .npmrc doesn't exist and there is one in the target, delete the one in the target
logger.info(`Deleting ${targetNpmrcPath}`); // Verbose
fs__WEBPACK_IMPORTED_MODULE_0__.unlinkSync(targetNpmrcPath);
}
}
catch (e) {
throw new Error(`Error syncing .npmrc file: ${e}`);
}
}
function isVariableSetInNpmrcFile(sourceNpmrcFolder, variableKey, supportEnvVarFallbackSyntax) {
const sourceNpmrcPath = `${sourceNpmrcFolder}/.npmrc`;
//if .npmrc file does not exist, return false directly
if (!fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(sourceNpmrcPath)) {
return false;
}
const trimmedNpmrcFile = _trimNpmrcFile({ sourceNpmrcPath, supportEnvVarFallbackSyntax });
const variableKeyRegExp = new RegExp(`^${variableKey}=`, 'm');
return trimmedNpmrcFile.match(variableKeyRegExp) !== null;
}
//# sourceMappingURL=npmrcUtilities.js.map
/***/ })
/******/ });
/************************************************************************/View on GitHub (pinned to 63e28dc964)
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
Example fix
// before
syncNpmrc('/nonexistent/repo/common/config/rush', targetFolder);
// after
const src = '/repo/common/config/rush';
if (fs.existsSync(`${src}/.npmrc`)) {
syncNpmrc(src, targetFolder);
} Defensive patterns
Strategy: try-catch
Validate before calling
const src = `${repoRoot}/common/config/rush/.npmrc`;
if (fs.existsSync(src) && !fs.statSync(src).isFile()) throw new Error('.npmrc path is not a file');
fs.accessSync(path.dirname(targetPath), fs.constants.W_OK); Type guard
function canSyncNpmrc(srcFolder, targetFolder) {
try { fs.accessSync(srcFolder + '/.npmrc', fs.constants.R_OK); fs.accessSync(targetFolder, fs.constants.W_OK); return true; } catch { return false; }
} Try / catch
try {
syncNpmrc(srcFolder, targetFolder);
} catch (e) {
console.error('npmrc sync failed:', e.message); // inspect inner cause
process.exit(1);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Error building local installation folder (${path__WEBPACK_IM
- Error cleaning the package install folder (${packageInstallF
- Unable to create installed.flag file in ${packageInstallFold
- Error syncing .npmrc file: ${e}
- Error building local installation folder (${path.join(baseFo
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/fc4fbbe27914956c.
Report an issue: GitHub.