twentyhq/twenty · error · Error
Failed to read file ${filePath}: ${error}
Error message
Failed to read file ${filePath}: ${error} What it means
Thrown by parseJsoncFile when reading the file fails for a reason other than JSONC parse errors — i.e. the readFile itself threw. This is the fallback catch for filesystem-level errors: file not found, permission denied, encoding errors, or disk I/O failures. The original error is stringified into the message.
Source
Thrown at packages/twenty-sdk/src/cli/utilities/file/file-jsonc.ts:57
parseErrors,
);
}
return result;
};
export const parseJsoncFile = async <T = object>(
filePath: string,
options: JsoncParseOptions = {},
): Promise<T> => {
try {
const content = await readFile(filePath, 'utf8');
return parseJsoncString(content, options);
} catch (error) {
if (error instanceof JsoncParseError) {
throw new JsoncParseError(error.message, error.parseErrors, filePath);
}
throw new Error(`Failed to read file ${filePath}: ${error}`);
}
};
View on GitHub (pinned to 1f5dd2bbd2)
Solutions
- Verify the file exists at the specified path using fs.access or fs.stat.
- Check file permissions — ensure the running process has read access.
- Confirm the path is a file, not a directory.
- If using a relative path, ensure the working directory is correct — prefer absolute paths.
Defensive patterns
Strategy: validation
Validate before calling
import { access } from 'node:fs/promises';
const canReadFile = async (filePath: string): Promise<boolean> => {
try {
await access(filePath);
return true;
} catch {
return false;
}
};
if (!(await canReadFile(filePath))) {
console.error(`Cannot read ${filePath}. Check path, permissions, and that it is a file.`);
return;
} Try / catch
import { parseJsoncFile } from '@/cli/utilities/file/file-jsonc';
try {
const data = await parseJsoncFile(configPath);
} catch (error) {
if (error instanceof Error && error.message.startsWith('Failed to read file')) {
const inner = error.message;
if (inner.includes('ENOENT')) console.error('File does not exist.');
else if (inner.includes('EACCES')) console.error('Permission denied.');
else if (inner.includes('EISDIR')) console.error('Path is a directory, not a file.');
process.exit(1);
}
throw error;
} Prevention
- Check file existence and permissions before attempting to parse.
- Use absolute paths to avoid working-directory ambiguity.
- Ensure the running process has read access to the target file.
When it happens
Trigger: Calling parseJsoncFile(filePath) where readFile(filePath) rejects — the file doesn't exist (ENOENT), the process lacks read permissions (EACCES), the path is a directory (EISDIR), or a disk error occurs. This is distinct from error 90 which handles JSONC syntax errors.
Common situations: The file path is wrong or the file was deleted between the path check and the read. The process doesn't have filesystem permissions to read the file. The path points to a directory instead of a file. A network-mounted filesystem is temporarily unavailable.
Related errors
- ${fileName} not found in ${appPath}
- JSONC parse errors:\n${errorMessages.join('\n')}
- Directory ${appDirectory} already exists and is not empty
- File is not valid XML
- EntityDescriptor element is missing
AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12).
Data as JSON: /api/errors/54a2533acf06be2d.
Report an issue: GitHub.