【问题标题】:npm ERR! Error: EPERM: operation not permitted, unlink Windows [duplicate]npm 错误!错误:EPERM:不允许操作,取消链接 Windows [重复]
【发布时间】:2020-03-05 03:46:14
【问题描述】:

我无法让 npm install 在 Angular 项目中工作。安装几乎完成,但失败了

npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! path C:\workspaces\my-project\my-module\node_modules\.staging\typescript-d1902bf5\lib\typescriptServices.js
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\workspaces\my-project\my-module\node_modules\.staging\typescript-d1902bf5\lib\typescriptServices.js'
npm ERR!  [OperationalError: EPERM: operation not permitted, unlink 'C:\workspaces\my-project\my-module\node_modules\.staging\typescript-d1902bf5\lib\typescriptServices.js'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, unlink 'C:\workspaces\my-project\my-module\node_modules\.staging\typescript-d1902bf5\lib\typescriptServices.js'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'unlink',
npm ERR!     path: 'C:\\workspaces\\my-project\my-module\\node_modules\\.staging\\typescript-d1902bf5\\lib\\typescriptServices.js'
npm ERR!   },
npm ERR!   stack: "Error: EPERM: operation not permitted, unlink 'C:\\workspaces\\my-project\my-module\\node_modules\\.staging\\typescript-d1902bf5\\lib\\typescriptServices.js'",
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'C:\\workspaces\\my-project\my-module\\node_modules\\.staging\\typescript-d1902bf5\\lib\\typescriptServices.js',
npm ERR!   parent: 'my-module'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

我尝试过的:

  • 以普通用户和管理员身份从 cmd、git bash 和 power shell 运行
  • 删除 node_modules 文件夹并重试
  • 为 Windows 安装 nvm 并安装 nodejs 12.13.0 LTS(然后安装 npm),然后尝试 npm install
  • 卸载 nvm for Windows 并使用站点的安装程序安装 nodejs 12.13.0 LTS,npm i -g npmnpm install
  • 在 Windows 安全设置中排除我的工作区目录
  • npm cache verify, npm install
  • npm cache clean --force, npm install

谁能提出一些我可能没有想到的建议?不幸的是,我无法发布我的 package.json 或 .npmrc,因为我使用的存储库不是公开的,但从错误的外观来看,它应该是无关紧要的。

更新

看起来这可能是一个竞争条件。见here。我使用的是 npm 版本 6.13.0。

另一个更新

我现在还有其他问题,但 Jonathan Irvin 的评论帮助了我,尤其是 this。我禁用了 Windows 索引并将所有权限授予我的用户。

【问题讨论】:

  • 确保关闭所有应用程序和/或重新启动计算机,其中一个可能已锁定文件。
  • 我也是,忘记写了;将更新问题。感谢您的意见。看起来这可能是一个竞争条件。见docs.npmjs.com/common-errors
  • 只要确保 VS Code 已关闭(如果您正在使用它)。否则,您可能会遇到权限问题。尝试将您的 repo 或项目克隆到其他文件夹中。

标签: node.js npm


【解决方案1】:

在项目的根目录下尝试npm unlink

【讨论】:

  • 您好,感谢您的评论。我也试过了,但没有用。我已经根据另一个用户的 cmets 更新了对我有用的答案。
猜你喜欢
  • 2023-03-07
  • 2019-11-04
  • 1970-01-01
  • 2022-12-18
  • 1970-01-01
  • 1970-01-01
  • 2018-02-15
  • 2017-01-10
  • 2019-09-10
相关资源
最近更新 更多