hcengineering/platform · error
Error syncing .npmrc file: ${e}
Error message
Error syncing .npmrc file: ${e} What it means
syncNpmrc() copies a source .npmrc into a target folder (creating or deleting as needed) and wraps any filesystem failure in this generic Error. It indicates the .npmrc sync step of the bootstrap failed — e.g. permission problems, missing folders, or unreadable source file.
Source
Thrown at foundations/net/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
- Check filesystem permissions on both the source and target .npmrc paths and the containing folders.
- Ensure the target folder exists and is writable before running the bootstrap (or create it manually).
- Inspect the wrapped inner error (${e}) in the message to identify the exact fs operation that failed.
- On Windows/CI, close processes locking the .npmrc or add retry/cleanup steps in the pipeline.
Example fix
// before
fs.mkdirSync(rushTempFolder, { recursive: true }) // missing -> EACCES later during syncNpmrc
// after
fs.mkdirSync(rushTempFolder, { recursive: true })
fs.chmodSync(rushTempFolder, 0o755) // ensure writable before syncNpmrc Defensive patterns
Strategy: try-catch
Validate before calling
const src = `${sourceFolder}/.npmrc`, dst = `${targetFolder}/.npmrc`
if (fs.existsSync(src) && !fs.accessSync(src, fs.constants.R_OK) === undefined) {}
fs.accessSync(path.dirname(dst), fs.constants.W_OK) // throws early if target dir not writable Try / catch
try {
syncNpmrc(sourceFolder, targetFolder)
} catch (e) {
console.error('npmrc sync failed; check permissions on', targetFolder, '\ncause:', e.message)
process.exit(1)
} Prevention
- Pre-create target folders with user-owned permissions before running bootstrap scripts.
- Avoid running installs with sudo, which leaves root-owned .npmrc files behind.
- On Windows, ensure no editor/AV locks .npmrc during CI.
- Read the wrapped inner error in the message to identify which exact fs op failed.
When it happens
Trigger: syncNpmrc(sourceNpmrcFolder, targetNpmrcFolder) is called and any fs operation inside the try block throws: reading the source .npmrc, writing/copying to the target, or unlinkSync on a stale target .npmrc.
Common situations: Read-only target directory (e.g. CI cache, mounted volume); source .npmrc missing while target exists and deletion fails; EACCES/EPERM from restrictive permissions; Windows file locks on the target .npmrc.
Related errors
- Unable to create package.json: ${e}
- Error cleaning the package install folder (${packageInstallF
- The NPM executable does not exist
- Error building local installation folder (${path__WEBPACK_IM
- Unable to create installed.flag file in ${packageInstallFold
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/cfb7fbb4267ff531.
Report an issue: GitHub.