繁体   English   中英

由于文件锁定,jenkins 上的 npm 安装失败

[英]npm install fails on jenkins due to file locking

我有一个 powershell 构建脚本,它在某个时候运行npm install 我在网上搜索了这个问题,但找不到任何有用的东西。 我看到有人建议在 jenkins 文件夹的Windows Defender中放置一个例外,因为它正在锁定文件。 我做到了,仍然没有运气。

我不认为脚本对我有任何锁定,我只是在运行 npm 安装。 奇怪的是,这并不总是发生,有时有效,有时无效。

26610 verbose stack Error: EPERM: operation not permitted, unlink 'C:\Jenkins\workspace\...\node_modules\.staging\highcharts-705cfa89\highcharts.src.js'
26612 verbose Windows_NT 10.0.18363
26613 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
26614 verbose node v12.18.2
26615 verbose npm  v6.14.5
26616 error code EPERM
26617 error syscall unlink
26618 error path C:\Jenkins\workspace\...\node_modules\.staging\highcharts-705cfa89\highcharts.src.js
26619 error errno -4048
26620 error Error: EPERM: operation not permitted, unlink 'C:\Jenkins\workspace\...\node_modules\.staging\highcharts-705cfa89\highcharts.src.js'
26620 error  [OperationalError: EPERM: operation not permitted, unlink 'C:\Jenkins\workspace\...\node_modules\.staging\highcharts-705cfa89\highcharts.src.js'] {
26620 error   cause: [Error: EPERM: operation not permitted, unlink 'C:\Jenkins\workspace\...\node_modules\.staging\highcharts-705cfa89\highcharts.src.js'] {
26620 error     errno: -4048,
26620 error     code: 'EPERM',
26620 error     syscall: 'unlink',
26620 error     path: 'C:\\Jenkins\\workspace\\...\\node_modules\\.staging\\highcharts-705cfa89\\highcharts.src.js'
26620 error   },
26620 error   errno: -4048,
26620 error   code: 'EPERM',
26620 error   syscall: 'unlink',
26620 error   path: 'C:\\Jenkins\\workspace\\...\\node_modules\\.staging\\highcharts-705cfa89\\highcharts.src.js',
26620 error   parent: 'react'
26620 error }
26621 error The operation was rejected by your operating system.
26621 error It's possible that the file was already in use (by a text editor or antivirus),
26621 error or that you lack permissions to access it.
26621 error
26621 error If you believe this might be a permissions issue, please double-check the
26621 error permissions of the file and its containing directories, or try running
26621 error the command again as root/Administrator.
26622 verbose exit [ -4048, true ]

尝试使用yarn install代替npm install

对于遇到此问题的任何人

package-lock.json是问题所在。 我们有一个我们使用的 npm 包的 proget 提要,但是package-lock.json将注册表设置为默认的 npm 注册表。 这就是导致问题的原因。

解决方案是删除package-lock.json文件,或者在使用正确的注册表运行npm install后提交它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM