{"record":{"id":"3cc38f908926876f","repo":"hcengineering/platform","slug":"unable-to-create-package-json-e","errorCode":null,"errorMessage":"Unable to create package.json: ${e}","messagePattern":"Unable to create package\\.json: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/communication/common/scripts/install-run.js","lineNumber":626,"sourceCode":"    }\n}\nfunction _createPackageJson(packageInstallFolder, name, version) {\n    try {\n        const packageJsonContents = {\n            name: 'ci-rush',\n            version: '0.0.0',\n            dependencies: {\n                [name]: version\n            },\n            description: \"DON'T WARN\",\n            repository: \"DON'T WARN\",\n            license: 'MIT'\n        };\n        const packageJsonPath = path__WEBPACK_IMPORTED_MODULE_3__.join(packageInstallFolder, PACKAGE_JSON_FILENAME);\n        fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContents, undefined, 2));\n    }\n    catch (e) {\n        throw new Error(`Unable to create package.json: ${e}`);\n    }\n}\n/**\n * Run \"npm install\" in the package install folder.\n */\nfunction _installPackage(logger, packageInstallFolder, name, version, command) {\n    try {\n        logger.info(`Installing ${name}...`);\n        const npmPath = getNpmPath();\n        const platformNpmPath = _getPlatformPath(npmPath);\n        const result = child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync(platformNpmPath, [command], {\n            stdio: 'inherit',\n            cwd: packageInstallFolder,\n            env: process.env,\n            shell: _isWindows()\n        });\n        if (result.status !== 0) {\n            throw new Error(`\"npm ${command}\" encountered an error`);","sourceCodeStart":608,"sourceCodeEnd":644,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/communication/common/scripts/install-run.js#L608-L644","documentation":"_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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nnode install-run.js pnpm@8 -- pnpm -v   # run as non-root in image with root-owned /home\n// after\nENV HOME=/tmp/home && RUN mkdir -p /tmp/home && chmod 777 /tmp/home","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nfs.accessSync(installFolder, fs.constants.W_OK);\nfs.statSync(installFolder).isDirectory() || (() => { throw new Error('install folder is not a directory'); })();","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["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"],"tags":["filesystem","permissions","npm"],"backgroundTag":"file-write-permission-denied","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}