Reputation: 2846
I installed Prisma and I run npx primsa db push
it pushed all tables to database successfully, after that I run npx prisma generate
it tried to install @prisma/client and it fails with this error message:
error An unexpected error occurred: "EPERM: operation not permitted, unlink 'path_to_project\node_modules\prisma\query_engine-windows.dll.node'
I tried to remove node_modules
and re-install all modules but it not worked.
Upvotes: 8
Views: 26426
Reputation: 1
Its due to the process which is currently using connection through Prisma
To solve this issue, you need to close any open Prisma Studio
any terminal that is running prisma
or any application that is using connection through Prisma
.
Close all processes and then try once again. Your problem will be solved now!
Upvotes: 0
Reputation: 21
$ npx prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Error:
EPERM: operation not permitted, unlink 'D:\Tutorials\app\app-backend\node_modules\.prisma\client\query_engine-windows.dll.node'
You might have ended up with something like this. I'm using Nest JS and Docker to run my application. Whenever there's is a server process, example whenever the server is up and running, it can't do operations like migration.
Solution 1:
Simply stop/kill the server and run npx prisma generate
.
Solution 2:
Build and run the docker container using docker-compose up
and then do the DB operations.
You are good to go.
Upvotes: 2
Reputation: 1
i stopped all running terminals and npx prisma migrate dev --name <name>
& npx prisma generate
... then it works
Upvotes: 0
Reputation: 11
If we are using prisma with NextJs and if we get this type of error -
Error:
EPERM: operation not permitted, unlink - <filePath>
then we can use following steps :
Ctrl+C
in terminal to stop servernpx prisma generate
Hope this will fix the issue.☕
Upvotes: 1
Reputation: 1
when you restart your server don't reload your page then run npx prisma generate, i promise it will work perfect, but if you reload your page, and you run the npx prisma generate it will give you error
Upvotes: 0
Reputation: 107
Close Other Applications: Ensure that no other applications are using the Prisma files or the .prisma/client
directory. Close any editors, terminals, or applications that might be accessing these files.
open tabs was holding a lock on the file or directory, preventing the operation from completing successfully.
close all tab
or
stop your npm server before running prisma generate
ctrl+c
npx prisma generate
Upvotes: 0
Reputation: 68
i had same problem, my solution is don't generate prisma when you running your app. Try generate your model data when you not running your app
Upvotes: 0
Reputation: 1
I had the same issue , Stop the running docker container and things work fine again
Upvotes: 0
Reputation: 309
Same error and same solution for some reason the folders/files that need to be modified conflict with each other, but if you stop the Node process serving your project, you can migrate without any issue.
Upvotes: 0
Reputation: 51
I had the same error when using npx prisma generate
command. I had to close the next js server that was using the prisma client. Try closing any development servers you have that uses the prisma client and then try running the command again.
Upvotes: 5
Reputation: 11
In my case, I had killed the running backend frameworks (NestJS/Express) which were using Prisama. And try again with npx prisama generate
.
It works.
Upvotes: 1
Reputation: 701
If you are running nextjs server. Close the server and try running the command again.
$ npx prisma generate
Upvotes: 56
Reputation: 319
Closing all processes and re-running the command worked for me.
Upvotes: 11
Reputation: 12007
Stopping my docker container running and closing vs code and reopening it, solved it for me.
Upvotes: 0
Reputation: 11
I had the same error but after installing Microsoft Visual C++ 2015 Redistributable it works fine now
Upvotes: 0
Reputation: 41
I had this same error type with a different package. In my case the thing that was causing the error was because it couldn't access the folder while the app was still running ie. from this issue https://github.com/yarnpkg/yarn/issues/2685
This was following npm cache clean --force not resolving it.
Upvotes: 3
Reputation: 2846
I had to install @prisma/client
manually with yarn add @prisma/client
then run npx prisma generate
it works perfectlly.
Upvotes: 3