{"record":{"id":"248968f1778b9a19","repo":"vercel/turborepo","slug":"unable-to-write-package-json","errorCode":null,"errorMessage":"Unable to write package.json","messagePattern":"Unable to write package\\.json","errorType":"exception","errorClass":"TransformError","httpStatus":null,"severity":"error","filePath":"packages/create-turbo/src/transforms/official-starter.ts","lineNumber":84,"sourceCode":"      if (packageJsonContent.devDependencies?.turbo) {\n        // if the user specified a turbo version, use that\n        if (opts.turboVersion) {\n          packageJsonContent.devDependencies.turbo = opts.turboVersion;\n          // use the same version as the create-turbo invocation\n        } else {\n          // eslint-disable-next-line @typescript-eslint/no-var-requires -- Have to go get package.json\n          const version = (require(\"../../package.json\") as { version: string })\n            .version;\n          packageJsonContent.devDependencies.turbo = `^${version}`;\n        }\n      }\n\n      try {\n        fs.writeJsonSync(rootPackageJsonPath, packageJsonContent, {\n          spaces: 2\n        });\n      } catch (err) {\n        throw new TransformError(\"Unable to write package.json\", {\n          transform: meta.name,\n          fatal: false\n        });\n      }\n    }\n  }\n\n  return { result: \"success\", metaJson, ...meta };\n}\n","sourceCodeStart":66,"sourceCodeEnd":94,"githubUrl":"https://github.com/vercel/turborepo/blob/f9245100cf0d31d96628804ead485f6bf226e55a/packages/create-turbo/src/transforms/official-starter.ts#L66-L94","documentation":"After patching the starter's package.json (project name, pinned turbo version), the official-starter transform writes it back with fs.writeJsonSync. It throws this TransformError when the write fails. Common causes are permission errors, a read-only file or directory, a full disk, or a file lock held by another process.","triggerScenarios":"fs.writeJsonSync on the extracted starter's package.json raises EACCES, EPERM, or EBUSY. The file is read-only, the directory is not writable, an editor or antivirus holds a lock, or the disk is full.","commonSituations":"Antivirus software on Windows locks recently written files during scaffolding. A read-only checkout or mount. A full disk late in the create process.","solutions":["Re-run create-turbo in a fresh writable directory","Add an antivirus exclusion for the creation directory, or temporarily pause real-time scanning, then retry","Check write permission on the extracted starter directory and the package.json file itself","Free disk space and confirm the volume allows writes"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import fs from \"node:fs\";\n\n// confirm the starter directory accepts writes before create-turbo patches it\nfs.accessSync(starterDir, fs.constants.W_OK);\nfs.accessSync(`${starterDir}/package.json`, fs.constants.W_OK);","typeGuard":null,"tryCatchPattern":"try {\n  fs.writeJsonSync(pkgPath, content, { spaces: 2 });\n} catch (err) {\n  const code = (err as NodeJS.ErrnoException).code;\n  if (code === \"EACCES\" || code === \"EPERM\" || code === \"EBUSY\") {\n    // retry once after a short delay; AV locks on Windows are transient\n    await new Promise((r) => setTimeout(r, 500));\n    fs.writeJsonSync(pkgPath, content, { spaces: 2 });\n  } else {\n    throw err;\n  }\n}","preventionTips":["Add the creation directory to antivirus exclusions on Windows","Close editors that hold files in the scaffold directory open","Keep the target volume writable and non-full before scaffolding"],"tags":["create-turbo","filesystem","permissions","package-json","scaffolding"],"backgroundTag":"permission-denied-write","analyzedSha":"f9245100cf0d31d96628804ead485f6bf226e55a","analyzedAt":"2026-08-17T10:46:15.696Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}