node.js - 由于文件锁定,jenkins 上的 npm 安装失败
问题描述
npm install
我有一个在某个时候运行的 powershell 构建脚本。我在网上搜索了这个问题,但找不到任何有用的东西。我看到有人建议在Windows Defender
jenkins 文件夹中放置一个例外,因为它正在锁定文件。我做到了,仍然没有运气。
我不认为脚本对我有任何锁定,我只是在运行 npm install。奇怪的是,这并不总是发生,有时有效,有时无效。
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 ]
解决方案
对于遇到此问题的任何人
这package-lock.json
就是问题所在。我们有一个我们使用的 npm 包的 proget 提要,但是package-lock.json
将注册表设置为默认的 npm 注册表。这就是导致问题的原因。
解决方案是删除文件或在使用正确的注册表package-lock.json
运行后提交它。npm install
推荐阅读
- python - Python将CSV转换为多个JSONS,每行一个
- javascript - 如何在 opencv.js 中使用 cv.polylines?
- java - 如何在 SpringBoot 中同时使用 log4j 和 logBack?
- sql - 将每个 id 的行转为列
- node.js - 将 internal.Writable 转换为 NodeJS.WritableStream
- kubernetes-helm - skaffold + helm 集成
- javascript - TypeError:无法读取长度未定义的属性?- 反应轮播
- android - 使用 ViewModel 和 Clean Code 在哪里放置数据格式以显示在 UI 中?
- c++ - C++20 模块“循环依赖”
- c# - WPF 显示设计器视图中不存在的空白