npm ERR!错误:EPERM:不允许操作,请断开Windows

时间:2019-11-08 13:44:26

标签: node.js npm

我无法在一个有角度的项目中安装npm。安装几乎完成,但失败

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
  • 通过站点的安装程序npm i -g npmnpm install卸载Windows的nvm并安装nodejs 12.13.0 LTS
  • 在Windows安全设置中排除我的工作区目录
  • npm cache verifynpm install
  • npm cache clean --forcenpm install

有人可以建议我可能没有想到的事情吗?不幸的是,我无法发布package.json或.npmrc,因为我正在使用的存储库不是公开的,但是从错误的外观来看,这应该是不相关的。

更新

看来这可能是比赛条件。参见here。我正在使用npm 6.13.0版本。

另一个更新

我现在还有其他问题,但乔纳森·欧文(Jonathan Irvin)的评论对我有帮助,尤其是this。我禁用了Windows索引编制并将所有权限授予了我的用户。

1 个答案:

答案 0 :(得分:0)

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