keystonejs / keystonejs/keystone

Local assets example throws an error on image upload

Open
#9,106 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
10k
Forks
1.3k
Avg merge
19h 14m
Merged PRs (30d)
19

Description

When running the `examples/assets-local` with `pnpm dev` and try to upload an image I get:

```txt
An error occurred while resolving input fields.
- Post.banner: require() of ES Module /home/jneidel/tmp/keystone/node_modules/.pnpm/file-type@19.0.0/node_modules/file-type/index.js from /home/jneidel/tmp/keystone/packages/core/src/lib/assets/createImagesContext.ts not supported.
Instead change the require of index.js in /home/jneidel/tmp/keystone/packages/core/src/lib/assets/createImagesContext.ts to a dynamic import() which is available in all CommonJS modules.
```

![screenshot_24-04-20_08:59:11](https://github.com/keystonejs/keystone/assets/25589715/808873aa-03b0-4f43-9ce8-8697c996ac05)

`node -v => v16.20.2`

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure in examples/assets-local with pnpm dev and an image upload, then inspect packages/core/src/lib/assets/createImagesContext.ts where the error originates. Confirm the fix by running the example on Node v16.20.2 and verifying that image uploads complete without the module-resolution error.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.