denoland/deno · error · TypeError
Object is not a valid image or a path to an image…
Error message
Object is not a valid image or a path to an image. `Deno.jupyter.image` supports displaying JPG or PNG images, or GPUTextures.
What it means
The stock-tsc/tsgo compatibility layer (`npm_compat`) generates a root tsconfig that maps jsr:/npm:/http(s): dependencies onto local mirror files under `.deno/`. This is a thin wrapper: `{e}` carries the real cause from the underlying generation routine (filesystem errors writing `.deno/`, unresolvable member paths, mirror-path failures, etc.), so the appended inner error is the thing to read.
Solutions
- Read the inner `{e}` cause — it names the actual failing operation
- Clear the generated cache directory (`rm -rf .deno`) and re-run to regenerate from scratch
- Ensure the project root is writable by the current user
- If the cause points at a specific URL, fix that import (use concrete file URLs rather than directories)
Example fix
# before $ deno check main.ts # Failed to generate tsconfig: ... (inner cause) # after $ rm -rf .deno && deno check main.ts # regenerated cleanly
Defensive patterns
Strategy: try-catch
Validate before calling
# Cheap pre-flight: writable project root and no stale generated tree
[ -w . ] || { echo 'project not writable'; exit 1; }
[ ! -d .deno ] || rm -rf .deno # regenerate cleanly Try / catch
When wrapping `deno check`/`deno sync-types` programmatically, capture stderr and split the message on ': ' — the tail after 'Failed to generate tsconfig:' is the real cause; branch on it (unwritable dir -> fix perms; specific URL -> fix the import) instead of retrying blindly.
Prevention
- Keep .deno/ out of version control and delete it after interrupted runs
- Ensure write permission on the project root in containers
- Prefer concrete file imports so mirror-path generation never hits ambiguous URLs
When it happens
Trigger: `deno check`/`deno sync-types` with the stock TypeScript compatibility pipeline when tsconfig generation fails underneath: unwritable or corrupted `.deno` directory, a remote module URL that cannot be mirrored (directory-like URL), invalid member paths in the workspace, or disk-full conditions.
Common situations: Read-only project directory in CI containers; a previously interrupted run left a malformed `.deno` tree; imports of directory-style URLs (`https://example.com/lib/`) inside the dependency graph; disk quota exhaustion.
Related errors
- Linter plugin name must be a string
- Cannot generate declarations for files with different…
- could not resolve the native TypeScript compiler; download
- Entry point must be a file
- ERR_INVALID_ARG_TYPE
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/61d50db1cf960e5e.
Report an issue: GitHub.
Appendix: source
Thrown at cli/js/40_jupyter.js:413
if (isJpg(obj)) {
return makeDisplayable({
"image/jpeg": core.ops.op_base64_encode_from_buffer(obj, 0, obj.length),
});
}
if (isPng(obj)) {
return makeDisplayable({
"image/png": core.ops.op_base64_encode_from_buffer(obj, 0, obj.length),
});
}
if (obj instanceof GPUTexture) {
return makeDisplayable({
"image/png": core.ops.op_jupyter_create_png_from_texture(obj),
});
}
throw new TypeError(
"Object is not a valid image or a path to an image. `Deno.jupyter.image` supports displaying JPG or PNG images, or GPUTextures.",
);
}
function isMediaBundle(obj) {
if (obj == null || typeof obj !== "object" || Array.isArray(obj)) {
return false;
}
for (const key in obj) {
if (typeof key !== "string") {
return false;
}
}
return true;
}
async function formatInner(obj, raw) {
if (raw && isMediaBundle(obj)) {View on GitHub (pinned to 9ad36f7a2c)