{"record":{"id":"499f6b355333c742","repo":"shadcn-ui/ui","slug":"no-package-json-file-found-ensure-you-are-at-th","errorCode":null,"errorMessage":"No `package.json` file found. Ensure you are at the root of your project.","messagePattern":"No `package\\.json` file found\\. Ensure you are at the root of your project\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/shadcn/src/migrations/cn/index.ts","lineNumber":27,"sourceCode":"  removeDependencies,\n} from \"@/src/utils/updaters/update-dependencies\"\nimport fsExtra from \"fs-extra\"\nimport prompts from \"prompts\"\n\nimport { resolveMigrationFiles } from \"./files\"\nimport { createCnTransformer } from \"./transform\"\nimport { OLD_PACKAGES, type CnMigrationIssue, type OldPackage } from \"./types\"\n\nexport { transformCnSource } from \"./transform\"\nexport type { CnMigrationIssue, CnSourceTransformResult } from \"./types\"\n\nexport async function migrateCn(options: {\n  cwd: string\n  path?: string\n  yes?: boolean\n}) {\n  if (!fsExtra.existsSync(path.resolve(options.cwd, \"package.json\"))) {\n    throw new Error(\n      \"No `package.json` file found. Ensure you are at the root of your project.\"\n    )\n  }\n\n  const files = await resolveMigrationFiles(options.cwd, options.path)\n  const contents = await Promise.all(\n    files.map((file) => fs.readFile(file, \"utf-8\"))\n  )\n  const transform = createCnTransformer()\n  const results = files.map((file, index) => {\n    const content = contents[index]\n    return { file, content, result: transform(content, file) }\n  })\n\n  const changedFiles = results.filter(\n    ({ content, result }) => content !== result.content\n  )\n  const unsupported = results.flatMap(({ file, result }) =>","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/shadcn-ui/ui/blob/5c7072da672b0048bc6771e3204063a2537df91a/packages/shadcn/src/migrations/cn/index.ts#L9-L45","documentation":"migrateCn is a project-level migration and needs a package.json at the working directory to locate dependencies and run package-manager commands. Before doing anything it checks fsExtra.existsSync(cwd/package.json) and throws this error if absent, telling you to run from the project root.","triggerScenarios":"Running `shadcn migrate cn` (or migrateCn) with cwd set to a directory containing no package.json — a subdirectory like src/, a parent directory, a temp folder, or an empty repo.","commonSituations":"Running the CLI from a monorepo root whose workspace apps live in subdirectories (or vice versa, running inside packages/app when the CLI expects the root), running in a freshly cloned repo before `npm install` generated nothing relevant, or in a non-Node project.","solutions":["cd into the directory containing package.json (project or app root) and rerun the migration.","In a monorepo, run from the workspace app that has the dependencies, or set cwd explicitly to that app.","If package.json is missing because the project was never initialized, run `npm init -y` (or your package manager's init) first."],"exampleFix":"// before\nawait migrateCn({ cwd: '/repo/packages/app/src' })\n// after\nawait migrateCn({ cwd: '/repo/packages/app' })","handlingStrategy":"validation","validationCode":"import { existsSync } from 'fs'\nimport { resolve } from 'path'\nif (!existsSync(resolve(process.cwd(), 'package.json'))) {\n  throw new Error('Run from the project root containing package.json')\n}\nawait migrateCn({ cwd: process.cwd() })","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run shadcn commands from the directory containing package.json.","In monorepos, target the workspace app directory that owns the dependencies.","Initialize the project with npm/pnpm init before running migrations."],"tags":["filesystem","project-root","cli"],"backgroundTag":"missing-config-file","analyzedSha":"5c7072da672b0048bc6771e3204063a2537df91a","analyzedAt":"2026-09-07T00:08:47.579Z","contentChangedAt":"2026-09-07T00:08:47.579Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}