hcengineering/platform · error
Unable to create package.json: ${e}
Error message
Unable to create package.json: ${e} What it means
_createPackageJson writes a minimal package.json (name 'ci-rush', dependencies omitted, MIT license) into packageInstallFolder so npm can install the requested package. If fs.writeFileSync fails (or JSON serialization throws), the error is wrapped as 'Unable to create package.json: <cause>'.
Source
Thrown at foundations/net/common/scripts/install-run.js:626
}
}
function _createPackageJson(packageInstallFolder, name, version) {
try {
const packageJsonContents = {
name: 'ci-rush',
version: '0.0.0',
dependencies: {
[name]: version
},
description: "DON'T WARN",
repository: "DON'T WARN",
license: 'MIT'
};
const packageJsonPath = path__WEBPACK_IMPORTED_MODULE_3__.join(packageInstallFolder, PACKAGE_JSON_FILENAME);
fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContents, undefined, 2));
}
catch (e) {
throw new Error(`Unable to create package.json: ${e}`);
}
}
/**
* Run "npm install" in the package install folder.
*/
function _installPackage(logger, packageInstallFolder, name, version, command) {
try {
logger.info(`Installing ${name}...`);
const npmPath = getNpmPath();
const platformNpmPath = _getPlatformPath(npmPath);
const result = child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync(platformNpmPath, [command], {
stdio: 'inherit',
cwd: packageInstallFolder,
env: process.env,
shell: _isWindows()
});
if (result.status !== 0) {
throw new Error(`"npm ${command}" encountered an error`);View on GitHub (pinned to 63e28dc964)
Solutions
- Check permissions and writability of the package install folder (and free disk space) before running.
- Delete the rush temp/install folder and re-run so it is recreated cleanly.
- Avoid concurrent install-run invocations sharing the same install folder.
- If permissions were changed by running as root previously, fix ownership (chown) of the temp directory.
Defensive patterns
Strategy: validation
Validate before calling
// Verify the install folder is writable before running the script
const fs = require('fs');
fs.mkdirSync(installFolder, { recursive: true });
fs.accessSync(installFolder, fs.constants.W_OK);
const probe = require('path').join(installFolder, '.write-probe');
fs.writeFileSync(probe, 'ok');
fs.unlinkSync(probe); Try / catch
try {
runInstallRun();
} catch (e) {
if (/Unable to create package\.json/.test(e.message)) {
console.error(`Install folder not writable or full: ${e.message}`);
// clean and re-create the folder once
require('fs').rmSync(packageInstallFolder, { recursive: true, force: true });
runInstallRun();
} else throw e;
} Prevention
- Ensure the rush temp/install folder is writable by the user running the script.
- Monitor free disk space in CI before dependency install steps.
- Fix ownership after any sudo-elevated runs in the same directory.
- Avoid concurrent runs that could delete the folder mid-write.
When it happens
Trigger: installAndRun → _createPackageJson, when the install folder is not writable (EACCES/EPERM), does not exist (ENOENT after a failed clean step), is on a full disk (ENOSPC), or the path is invalid/locked on Windows.
Common situations: Read-only CI workspace or cache directory; disk quota exceeded; the folder was deleted between the clean and write steps by a concurrent process; permissions broken by a previous sudo-invoked run.
Related errors
- Unable to create package.json: ${e}
- Error building local installation folder (${path__WEBPACK_IM
- Unable to create package.json: ${e}
- Unable to create installed.flag file in ${packageInstallFold
- Error building local installation folder (${path__WEBPACK_IM
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/939212c7a876e39a.
Report an issue: GitHub.