{"record":{"id":"b5e51850de508515","repo":"mjmlio/mjml","slug":"specified-filepath-does-not-exist","errorCode":null,"errorMessage":"Specified filePath does not exist","messagePattern":"Specified filePath does not exist","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mjml-cli/src/helpers/fileContext.js","lineNumber":23,"sourceCode":"  /<mj-include[^<>]+path=['\"](.*(?:\\.mjml|\\.css|\\.html))['\"]\\s*[^<>]*(\\/>|>\\s*<\\/mj-include>)/gi\n\nconst ensureIncludeIsSupportedFile = (file) =>\n  path.extname(file).match(/\\.mjml|\\.css|\\.html/) ? file : `${file}.mjml`\n\nconst error = (e) => console.error(e.stack || e) // eslint-disable-line no-console\n\nexport default (baseFile, filePath) => {\n  const filesIncluded = []\n\n  let filePathDirectory = ''\n  if (filePath) {\n    try {\n      const isFilePathDir = fs.lstatSync(filePath).isDirectory()\n\n      filePathDirectory = isFilePathDir ? filePath : path.dirname(filePath)\n    } catch (e) {\n      if (e.code === 'ENOENT') {\n        throw new Error('Specified filePath does not exist')\n      } else {\n        throw e\n      }\n    }\n  }\n\n  const readIncludes = (dir, file, base) => {\n    const currentFile = path.resolve(\n      dir\n        ? path.join(dir, ensureIncludeIsSupportedFile(file))\n        : ensureIncludeIsSupportedFile(file),\n    )\n\n    const currentDirectory = path.dirname(currentFile)\n\n    const includes = new RegExp(includeRegexp)\n\n    let content","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/mjmlio/mjml/blob/6c01d35af5da14108b86bbf052232e99de7ca755/packages/mjml-cli/src/helpers/fileContext.js#L5-L41","documentation":"mjml-cli's fileContext helper resolves the directory containing an input file by lstat-ing the given filePath. If the path cannot be stat-ed at all (fs.lstatSync throws ENOENT), the helper re-throw a clearer Error('Specified filePath does not exist') instead of leaking the raw ENOENT. It is a guard against running mjml CLI commands on a file or directory path that is not on disk.","triggerScenarios":"Running a CLI command that resolves a file context (e.g. mjml --watch or compile helpers) with an input/output path that does not exist; passing a relative path from a different working directory; a glob or config pointing at a deleted/moved file.","commonSituations":"Typo in the mjml file name on the command line; running mjml before the input file is generated by a build step; a watch configuration referencing a file that was renamed or deleted; wrong cwd when using relative paths in scripts or CI.","solutions":["Verify the path exists with ls/test -f before invoking mjml and correct typos.","Run the command from the directory containing the file, or pass an absolute path.","If the file is build-generated, ensure the preceding build step ran and produced it.","Wrap the mjml invocation in a check like fs.existsSync(filePath) in scripts."],"exampleFix":"// before\nmjml ./template.mjml -o ./out.html   // ENOENT: template.mjml missing\n// after\nls ./template.mjml                   # confirm it exists / fix the path\nmjml ./templates/newsletter.mjml -o ./out.html","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nif (!fs.existsSync(filePath)) throw new Error(`Input not found: ${filePath}`);","typeGuard":null,"tryCatchPattern":"try {\n  runMjmlCli(args)\n} catch (e) {\n  if (e.message === 'Specified filePath does not exist') {\n    console.error(`Path not found: ${args[0]}. cwd=${process.cwd()}`)\n    process.exit(1)\n  }\n  throw e\n}","preventionTips":["Use absolute paths in scripts and CI configs.","Check file existence in build steps before invoking the CLI.","Keep watch/glob configs in sync with actual file locations."],"tags":["cli","filesystem","missing-file","path"],"backgroundTag":"file-not-found","analyzedSha":"6c01d35af5da14108b86bbf052232e99de7ca755","analyzedAt":"2026-09-02T21:31:03.649Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}