keystonejs / keystonejs/keystone

npm run dev fails with EPERM error on WIndows

Open
#9,779 4 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

After tinkering a bit with a new Keystone 6 project, the `npm run dev` command started failing with the following error:

```
Error: EPERM: operation not permitted, rename 'C:\Users\...\node_modules\.prisma\client\query_engine-windows.dll.node.tmp34132' -> 'C:\Users\...\node_modules\.prisma\client\query_engine-windows.dll.node'
at async Object.rename (node:internal/fs/promises:782:10)
at async overwriteFile (C:\Users\...\node_modules\@prisma\client\generator-build\index.js:4477:5)
at async generateClient (C:\Users\...\node_modules\@prisma\client\generator-build\index.js:10035:7)
at async LineStream. (C:\Users\...\node_modules\@prisma\client\generator-build\index.js:4380:24
```

It looks like this happens if I `import ".prisma/client"` in `keystone.ts` (I wanted to export a `context` object to be used by a frontend app). It also seems to make starting the dev server quite a lot slower.

This error does not happen if I run the project within WSL.

- Node v24.13.1
- NPM 11.8.0
- @keystone-6/auth 8.1.0
- @keystone-6/core 6.5.1

I fixed it by putting the code to build and export the `context` object in its own file but the error stumped me for quite a while. Maybe you could detect it ahead of time and warn users to not do that?

Contributor guide

Open the contributing guide

Research direction

Start with the keystone.ts import of ".prisma/client" and reproduce the failure with npm run dev on Windows. Trace the @prisma/client generator-build stack shown in the report; done means the problematic setup is detected and users receive a warning, or the EPERM failure no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.