Search code examples
dockercontinuous-integrationgitlabpipelinecontinuous-deployment

Error: Missing binding "binding.node" after merge to main branch


I tried to configure automated code coverage in CI/CD in one of my branches in GitLab, and the pipeline passed perfectly within the branch, but when the admin merged the changes into the main branch, the pipeline failed due to a missing binding.

I used gitlab-ci.yml to configure my jobs in. I didn't have any experience working with pipelines, so this was pretty much a trial and error task for me.

Finally I got the configuration that was working for me that didn't break anything and produced the coverage as required. However, since it was showing a no space error prior to a successful build, I had to force clear the cache to get the jobs to run properly. Within my branch, the pipeline passed without any errors and I double checked by re-running it several times. But once the admin merged the branch it suddenly started producing the following error:

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 

side note: The branch I was working on had been checked out from the main branch, no changes from other branches had been included into this one.

I wanted to know:

  • what part of my code caused this error (i suspect force clearing the cache, but just a hunch)

  • why this error did not appear in the pipeline of the branch I was working in?

  • why is the runner giving an error when it has bindings for an updated version of Node? Shouldn't it be backward compatible?

I've looked at this link, but I'm curious as to why this error never occurred before merge and even if it did, why is it giving me an error because I have an updated version installed.

Here is my gitlab-ci.yml file:

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

Solution

  • I had the same problem and npm rebuild node-sass command didn't work for me. The reason was the npm cache. If you clear the cache, issue would be resolved.

    Steps followed:

    • Remove node modules rm -rf node_modules/
    • Remove cache npm cache clean --force
    • Verify cache removed npm cache verify
    • npm install