{"record":{"id":"2bc190e4ff2ed5eb","repo":"parcel-bundler/parcel","slug":"path-relative-process-cwd-source-is-not-a-f","errorCode":null,"errorMessage":"${path.relative(process.cwd(), source)} is not a file.","messagePattern":"(.+?) is not a file\\.","errorType":"exception","errorClass":"ThrowableDiagnostic","httpStatus":null,"severity":"error","filePath":"packages/core/core/src/requests/EntryRequest.js","lineNumber":133,"sourceCode":"            filePath: pkgFilePath,\n            codeHighlights: generateJSONCodeHighlights(contents, [\n              {\n                key: keyPath,\n                type: 'value',\n              },\n            ]),\n          },\n        ],\n        hints: alternatives.map(r => {\n          return md`Did you mean '__${r}__'?`;\n        }),\n      },\n    });\n  }\n\n  if (!stat.isFile()) {\n    let contents = await fs.readFile(pkgFilePath, 'utf8');\n    throw new ThrowableDiagnostic({\n      diagnostic: {\n        origin: '@parcel/core',\n        message: md`${path.relative(process.cwd(), source)} is not a file.`,\n        codeFrames: [\n          {\n            filePath: pkgFilePath,\n            codeHighlights: generateJSONCodeHighlights(contents, [\n              {\n                key: keyPath,\n                type: 'value',\n              },\n            ]),\n          },\n        ],\n      },\n    });\n  }\n}","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/core/src/requests/EntryRequest.js#L115-L151","documentation":"Thrown by assertFile() when fs.stat(source) succeeds but stat.isFile() returns false — the path exists but is a directory (or a socket/device). Parcel shows a code frame in package.json at the source value so the developer knows which field points at a non-file.","triggerScenarios":"Called from resolveEntry() after stat() resolves successfully. The path path.join(entry, relativeSource) resolves to a directory or special file rather than a regular file, so stat.isFile() is false.","commonSituations":"source field points to a folder name instead of a file inside it (e.g. \"src\" instead of \"src/index.html\"); accidentally created a directory with the same name as the intended entry file; pointing source at a node_modules package directory rather than its main file.","solutions":["Change the source path to point at the specific file, not the containing directory.","If you intended a directory entry, add a package.json with a source field inside that directory instead.","Verify with ls -la that the path is a regular file, not a directory.","Check for accidental file-vs-directory name collisions (e.g., a folder named index.html)."],"exampleFix":"// before — package.json\n{\n  \"source\": \"src\"\n}\n\n// after\n{\n  \"source\": \"src/index.html\"\n}","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst path = require('path');\nfunction validateSourceIsFile(pkgPath) {\n  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));\n  const source = Array.isArray(pkg.source) ? pkg.source[0] : pkg.source;\n  if (!source) return;\n  const full = path.join(path.dirname(pkgPath), source);\n  const stat = fs.statSync(full);\n  if (!stat.isFile()) {\n    throw new Error(`Source \"${source}\" is a ${stat.isDirectory() ? 'directory' : 'non-file'}, expected a file.`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always specify the full file path (with extension) in source, not a directory.","Verify source targets with ls -la in a prebuild check.","Avoid naming a directory the same as an intended entry file."],"tags":["entry","package-json","filesystem","config"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}