{"record":{"id":"f598ed099e8cd377","repo":"angular/angular-cli","slug":"as-of-angular-devkit-version-8-0-the-chokidar-p","errorCode":null,"errorMessage":"As of angular-devkit version 8.0, the \"chokidar\" package must be installed in order to use watch() features.","messagePattern":"As of angular-devkit version 8\\.0, the \"chokidar\" package must be installed in order to use watch\\(\\) features\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/core/node/host.ts","lineNumber":47,"sourceCode":"    await fsPromises.access(path, constants.F_OK);\n\n    return true;\n  } catch {\n    return false;\n  }\n}\n\n// This will only be initialized if the watch() method is called.\n// Otherwise chokidar appears only in type positions, and shouldn't be referenced\n// in the JavaScript output.\nlet FSWatcher: typeof import('chokidar').FSWatcher;\nfunction loadFSWatcher() {\n  if (!FSWatcher) {\n    try {\n      FSWatcher = require('chokidar').FSWatcher;\n    } catch (e) {\n      if ((e as NodeJS.ErrnoException).code !== 'MODULE_NOT_FOUND') {\n        throw new Error(\n          'As of angular-devkit version 8.0, the \"chokidar\" package ' +\n            'must be installed in order to use watch() features.',\n          {\n            cause: e,\n          },\n        );\n      }\n      throw e;\n    }\n  }\n}\n\n/**\n * An implementation of the Virtual FS using Node as the background. There are two versions; one\n * synchronous and one asynchronous.\n */\nexport class NodeJsAsyncHost implements virtualFs.Host<Stats> {\n  get capabilities(): virtualFs.HostCapabilities {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/core/node/host.ts#L29-L65","documentation":"The devkit's NodeJSAsyncHost/watch support uses chokidar's FSWatcher, which is treated as an optional peer dependency. loadFSWatcher tries require('chokidar'); if the require fails with MODULE_NOT_FOUND it throws this explanatory error telling you to install chokidar. (The odd message placement means any other require failure is rethrown as-is.) It exists because watch() features were moved to depend on an optional chokidar package in angular-devkit 8.0.","triggerScenarios":"Calling watch() (or any API that watches the filesystem via the devkit node host) in a project where the chokidar package is not resolvable from node_modules.","commonSituations":"Upgrading angular-devkit from <8.0 where chokidar was bundled, pnpm/yarn strict dependency hoisting hiding chokidar, minimal installs (npm install --omit=optional) dropping chokidar, custom CLI tooling built on @angular-devkit/core without declaring chokidar.","solutions":["Install chokidar: npm install chokidar (a version compatible with your devkit major version)","If using pnpm/yarn PnP, add chokidar as an explicit dependency of the package using @angular-devkit/core","Re-enable optional dependency installation (drop --omit=optional) and reinstall"],"exampleFix":"// before\nnpm install @angular-devkit/core\n// after\nnpm install @angular-devkit/core chokidar","handlingStrategy":"fallback","validationCode":"let chokidarAvailable = false;\ntry { require.resolve('chokidar'); chokidarAvailable = true; } catch {}\nif (!chokidarAvailable && needsWatch) {\n  throw new Error('watch() requires chokidar: npm install chokidar');\n}","typeGuard":"function hasChokidar(): boolean {\n  try { require.resolve('chokidar'); return true; } catch { return false; }\n}","tryCatchPattern":"try {\n  const watcher = host.watch(path, options);\n  // ...use watcher\n} catch (e) {\n  if ((e as Error).message.includes('chokidar')) {\n    // fallback: polling with fs.watch / setInterval, or fail fast with install instructions\n  } else { throw e; }\n}","preventionTips":["Explicitly list chokidar in package.json dependencies of any package using @angular-devkit/core watch","Avoid npm install --omit=optional in environments that need watch features","With pnpm, use public-hoist-pattern or direct dependency to make chokidar resolvable","After devkit major upgrades, re-verify optional peer deps resolve from the consuming project"],"tags":["chokidar","watch","missing-dependency","file-watching"],"backgroundTag":"missing-optional-dependency","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}