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 (with the requested package as a dependency) into the temporary install folder using fs.writeFileSync. If the write fails for any reason, the error is wrapped as "Unable to create package.json". This is a hard prerequisite for the subsequent npm install step.
Source
Thrown at foundations/server/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
- Ensure common/temp exists and is writable by the current user
- Clear common/temp/install-run and re-run to remove any half-deleted state
- Free disk space or raise the quota on the CI machine
- Avoid running multiple install-run invocations concurrently against the same repo temp folder
Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs')
fs.mkdirSync('common/temp/install-run', { recursive: true })
fs.accessSync('common/temp/install-run', fs.constants.W_OK)
fs.accessSync('.', fs.constants.W_OK) // approximate disk writability check Prevention
- Ensure the repo temp folder exists and is writable before running install-run
- Check free disk space in CI before install steps
- Serialize install-run executions to avoid racing folder cleanup
When it happens
Trigger: The package install folder under common/temp/install-run does not exist, was removed concurrently, or is not writable; disk full; path length/permission issues on Windows.
Common situations: CI runners with read-only caches; another concurrent install-run process deleted the folder mid-run; disk quota exceeded on shared CI machines.
Related errors
- Error cleaning the package install folder (${packageInstallF
- The NPM executable does not exist
- Error building local installation folder (${path__WEBPACK_IM
- Error cleaning the package install folder (${packageInstallF
- Unable to create package.json: ${e}
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/d1878a543bd4d701.
Report an issue: GitHub.