错误发生意外错误:“EPERM:不允许操作,取消链接 'path_to_project\node_modules\prisma\query_engine-windows.dll.node'

error An unexpected error occurred: "EPERM: operation not permitted, unlink 'path_to_project\\node_modules\\prisma\\query_engine-windows.dll.node'

我安装了 Prisma,我 运行 npx primsa db push 它成功地将所有表推送到数据库,之后我 运行 npx prisma generate 它尝试安装 @prisma/client 并且失败并显示此错误消息:

error An unexpected error occurred: "EPERM: operation not permitted, unlink 'path_to_project\node_modules\prisma\query_engine-windows.dll.node'

我尝试删除 node_modules 并重新安装所有模块,但没有成功。

我不得不使用 yarn add @prisma/client 手动安装 @prisma/client 然后 运行 npx prisma generate 它完美运行。

我用不同的包遇到了同样的错误类型。在我的例子中,导致错误的原因是因为当应用程序仍然 运行 即它无法访问该文件夹。从这个问题 https://github.com/yarnpkg/yarn/issues/2685

这是在 npm cache clean --force 未解析之后发生的。

我有同样的错误,但在安装 Microsoft Visual C++ 2015 Redistributable 后它现在可以正常工作了