hcengineering/platform · error · 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", MIT license) into the package install folder so npm install can run there. A failure of writeFileSync — typically permission denied or the folder being read-only — is wrapped as this error.
Source
Thrown at foundations/communication/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 the process user can write to the package install folder (fix permissions or RUSH_TEMP_FOLDER).
- Free disk space / raise quota if the disk is full.
- Remove conflicting paths where package.json exists as a directory.
- Prevent concurrent runs against the same install folder, then rerun.
Example fix
// before node install-run.js pnpm@8 -- pnpm -v # run as non-root in image with root-owned /home // after ENV HOME=/tmp/home && RUN mkdir -p /tmp/home && chmod 777 /tmp/home
Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs');
fs.accessSync(installFolder, fs.constants.W_OK);
fs.statSync(installFolder).isDirectory() || (() => { throw new Error('install folder is not a directory'); })(); Try / catch
try { runInstall(); } catch (e) { if (/Unable to create package\.json/.test(e.message)) { console.error('Cannot write package.json in install folder; check permissions and disk space'); process.exit(1); } throw e; } Prevention
- Run as a user with write access to the temp/home directory
- Monitor CI disk usage to avoid ENOSPC mid-install
- Don't share or mutate the install folder from other processes during a run
When it happens
Trigger: writeFileSync of the package.json into packageInstallFolder throws: no write permission on the folder, disk full, path is actually a directory, or the folder was removed between creation and write.
Common situations: Running in a container as a non-root user without write access to the temp folder; disk quota exceeded on CI runners; another process deleting/locking the install folder mid-run; read-only home directory.
Related errors
- Error syncing .npmrc file: ${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/3cc38f908926876f.
Report an issue: GitHub.