docker - 错误:合并到主分支后缺少绑定“binding.node”
问题描述
我尝试在 GitLab 的一个分支中配置 CI/CD 中的自动代码覆盖,并且管道在分支内完美通过,但是当管理员将更改合并到主分支时,管道由于缺少绑定而失败。
我曾经gitlab-ci.yml
在其中配置我的工作。我没有任何使用管道的经验,所以这对我来说几乎是一个反复试验的任务。
最后,我得到了对我有用的配置,它没有破坏任何东西,并根据需要生成了覆盖范围。但是,由于它在成功构建之前显示没有空间错误,因此我不得不强制清除缓存以使作业正常运行。在我的分支中,管道没有任何错误地通过,我通过重新运行它多次进行了仔细检查。但是一旦管理员合并了分支,它突然开始产生以下错误:
ERROR in Module build failed: Error: Missing binding /builds/internal/employee_portal/node_modules/node-sass/vendor/linux-x64-64/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 10.x
Found bindings for the following environments:
- Linux 64-bit with Node.js 11.x
This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.
at module.exports (/builds/internal/employee_portal/node_modules/node-sass/lib/binding.js:15:13)
at Object.<anonymous> (/builds/internal/employee_portal/node_modules/node-sass/lib/index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.sassLoader (/builds/internal/employee_portal/node_modules/sass-loader/lib/loader.js:46:72)
ERROR in ./src/styles.scss
Module build failed: ModuleBuildError: Module build failed: Error: Missing binding /builds/internal/employee_portal/node_modules/node-sass/vendor/linux-x64-64/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 10.x
Found bindings for the following environments:
- Linux 64-bit with Node.js 11.x
This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.
at module.exports (/builds/internal/employee_portal/node_modules/node-sass/lib/binding.js:15:13)
at Object.<anonymous> (/builds/internal/employee_portal/node_modules/node-sass/lib/index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.sassLoader (/builds/internal/employee_portal/node_modules/sass-loader/lib/loader.js:46:72)
at runLoaders (/builds/internal/employee_portal/node_modules/webpack/lib/NormalModule.js:244:20)
at /builds/internal/employee_portal/node_modules/loader-runner/lib/LoaderRunner.js:364:11
at /builds/internal/employee_portal/node_modules/loader-runner/lib/LoaderRunner.js:230:18
at runSyncOrAsync (/builds/internal/employee_portal/node_modules/loader-runner/lib/LoaderRunner.js:143:3)
at iterateNormalLoaders (/builds/internal/employee_portal/node_modules/loader-runner/lib/LoaderRunner.js:229:2)
at Array.<anonymous> (/builds/internal/employee_portal/node_modules/loader-runner/lib/LoaderRunner.js:202:4)
at Storage.finished (/builds/internal/employee_portal/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)
at provider (/builds/internal/employee_portal/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9)
at /builds/internal/employee_portal/node_modules/graceful-fs/graceful-fs.js:90:16
at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
ERROR: Job failed: exit code 1
旁注:我正在处理的分支已从主分支中签出,其他分支中没有包含任何更改。
我想知道:
我的代码的哪一部分导致了这个错误(我怀疑强制清除缓存,但只是预感)
为什么这个错误没有出现在我工作的分支的管道中?
为什么运行器在绑定了更新版本的 Node 时会出错?它不应该向后兼容吗?
我看过这个链接,但我很好奇为什么这个错误在合并之前从未发生过,即使它发生了,为什么它给我一个错误,因为我安装了更新版本。
这是我的gitlab-ci.yml
文件:
image: trion/ng-cli-karma
cache:
paths:
- node_modules/
build:
stage: build
script:
- npm cache clear --force
- npm i @angular/cli
- npm install
- npm run generate-docs
- ./node_modules/.bin/ng build --prod --base-href . --output-path www/
artifacts:
paths:
- www/
- documentation/
variables:
DOCKER_DRIVER: overlay
test:
stage: test
script:
- ./node_modules/.bin/ng test --code-coverage=true
artifacts:
paths:
- coverage/
coverage: '/(\d*.?\d+)%/'
pages:
stage: deploy
dependencies:
- build
- test
script:
- ls
- mv documentation www/
- mv coverage/ www/
- mv www/ public
- ls public/
artifacts:
paths:
- public
expire_in: 30 days
解决方案
我遇到了同样的问题,npm rebuild node-sass
命令对我不起作用。原因是 npm 缓存。如果您清除缓存,问题将得到解决。
后续步骤:
- 移除节点模块
rm -rf node_modules/
- 删除缓存
npm cache clean --force
- 验证缓存已删除
npm cache verify
npm install
推荐阅读
- vue.js - 在 Vue [警告] 中需要一个对象或数组值
- java - 场景大纲中的多个示例在 Eclipse IDE 中给出错误(示例中缺少 EOF :),我该如何解决?
- angular - 我正在尝试创建一个列表列表,其中我的内部列表为每个索引“i”获得相同的值
- laravel - 为什么在我成功安装 npm 时“npm run dev”不工作?
- javascript - 删除 v-for 数组中的特定组件
- java - firebase 用户在第一次调用后每次都返回 null
- css - style.css 模块解析失败:意外令牌 (2:20) 您可能需要适当的加载程序
- c# - 如何解决 System.Data.Entity.Infrastructure.DbUpdateException
- git - 是什么导致了致命:错误的修订以及如何修复这个 git 命令?
- javascript - 从不希望我拥有它的组件中获取 mousemove 事件