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

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

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

Related

Openshift build fails only in a specific project (with meteor error)

Using Openshift 4.6.
I'm trying to build an image with a buildConfig, a docker strategy from a binary source (local directory). The buildConfig is generated with the command:
oc new-build . name=build-name --strategy=docker --to=registry-url/image-name:tag --push-secret=secret-name --to-docker.
The build is started with the command:
oc start-build build-name --from-dir=. --wait --follow
The base image is pulled properly and the local Dockerfile starts executing. The dockerfile involves usage of meteor command, and it's okay as the base image contains meteor in /root directory and I'm running everything with --allow-superuser.
When running any meteor command (even --version), the build fails with:
## There is an issue with `node-fibers` ##
`/root/.meteor/packages/meteor-tool/.2.2.0.1jauib.qcbe++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/fibers/bin/linux-x64-57-glibc/fibers.node` is missing.
Try running this to fix the issue: /root/.meteor/packages/meteor-tool/.2.2.0.1jauib.qcbe++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/bin/node /root/.meteor/packages/meteor-tool/.2.2.0.1jauib.qcbe++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/fibers/build
SyntaxError: Invalid regular expression
Error: Missing binary. See message above.
at Object.<anonymous> (/root/.meteor/packages/meteor-tool/.2.2.0.1jauib.qcbe++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/fibers/fibers.js:20:8)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/opt/meteor/dist/bundle/programs/server/boot.js:1:75)
at Module._compile (module.js:635:30)
The file fibers.node definitely exists, as when I run in the Dockerfile echo $(ls -la ) it prints fibers.node.
To complicate things more, this problem only occurs when building in a specific project (namespace). When running the same buildConfig, with same secrets, in different projects it works well. Unfortunately, I need this project.
What can be the cause of faulty build in a specific namespace? Otherwise, there are no problen with it and it has more than sufficient resources and limits

Rails/NPM - Module build failed [ERR_PACKAGE_PATH_NOT_EXPORTED] for babel-loader

I have a Rails app and something recently changed in such a way that the rails server will start but when I load a page I get an NPM related error in the browser console. I did not set up NPM/VueJS in this app so need some help getting it running locally...
Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main resolved in /Users/meltemi/rails/myapp/node_modules/#babel/helper-compilation-targets/package.json
at applyExports (internal/modules/cjs/loader.js:524:9)
at resolveExports (internal/modules/cjs/loader.js:541:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:661:22)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:963:27)
at Function.Module._load (internal/modules/cjs/loader.js:859:27)
at Module.require (internal/modules/cjs/loader.js:1036:19)
at require (/Users/meltemi/rails/myapp/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/Users/meltemi/rails/myapp/node_modules/#babel/preset-env/lib/debug.js:8:33)
at Module._compile (/Users/meltemi/rails/myapp/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Module.require (internal/modules/cjs/loader.js:1036:19)
at require (/Users/meltemi/rails/myapp/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/Users/meltemi/rails/myapp/node_modules/#babel/preset-env/lib/index.js:11:14)
at Module._compile (/Users/meltemi/rails/myapp/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Module.require (internal/modules/cjs/loader.js:1036:19)
at require (/Users/meltemi/rails/myapp/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at requireModule (/Users/meltemi/rails/myapp/node_modules/#babel/core/lib/config/files/plugins.js:165:12)
at loadPreset (/Users/meltemi/rails/myapp/node_modules/#babel/core/lib/config/files/plugins.js:83:17)
at createDescriptor (/Users/meltemi/rails/myapp/node_modules/#babel/core/lib/config/config-descriptors.js:154:9)
at /Users/meltemi/rails/myapp/node_modules/#babel/core/lib/config/config-descriptors.js:109:50
at Array.map (<anonymous>)
at createDescriptors (/Users/meltemi/rails/myapp/node_modules/#babel/core/lib/config/config-descriptors.js:109:29)
at createPresetDescriptors (/Users/meltemi/rails/myapp/node_modules/#babel/core/lib/config/config-descriptors.js:101:10)
at presets (/Users/meltemi/rails/myapp/node_modules/#babel/core/lib/config/config-descriptors.js:47:19)
at mergeChainOpts (/Users/meltemi/rails/myapp/node_modules/#babel/core/lib/config/config-chain.js:320:26)
at /Users/meltemi/rails/myapp/node_modules/#babel/core/lib/config/config-chain.js:283:7
at Generator.next (<anonymous>)
at buildRootChain (/Users/meltemi/rails/myapp/node_modules/#babel/core/lib/config/config-chain.js:90:27)
at buildRootChain.next (<anonymous>)
at loadPrivatePartialConfig (/Users/meltemi/rails/myapp/node_modules/#babel/core/lib/config/partial.js:95:62)
at loadPrivatePartialConfig.next (<anonymous>)
This is similar to an issue reported recently in this SO post but in that case NPM wasn't embedded in a Rails app. Regardless I tried their solution by removing node_modules (there is no package-lock.json) and running npm install but that led to more errors in the shell:
$ npm install
npm WARN deprecated postcss-cssnext#3.1.0: 'postcss-cssnext' has been deprecated in favor of 'postcss-preset-env'. Read more at https://moox.io/blog/deprecating-cssnext/
npm WARN deprecated mkdirp#0.5.4: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated popper.js#1.16.1: You can find the new Popper v2 at #popperjs/core, this package is dedicated to the legacy v1
npm WARN deprecated browserslist#2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated core-js#2.6.11: core-js#<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js#3.
npm WARN deprecated browserslist#1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm ERR! code 1
npm ERR! Command failed: git checkout ^2.4.0
npm ERR! error: pathspec '^2.4.0' did not match any file(s) known to git
npm ERR!
This app is working in production so I'm not interested in updating outdated libraries at the moment. I'm not an NPM/JS guru so would appreciate any advice no matter how rudimentary this probably is. Thanks!
Edit: Results of yarn install --check-files as per request
$ yarn install --check-files
yarn install v1.22.4
[1/5] 🔍 Validating package.json...
[2/5] 🔍 Resolving packages...
[3/5] 🚚 Fetching packages...
[4/5] 🔗 Linking dependencies...
[5/5] 🔨 Building fresh packages...
$ node -e "try { require('fs').symlinkSync('../../node_modules/#bower_components', 'vendor/assets/components', 'junction') } catch (e) { }"
✨ Done in 10.22s.
Are you using yarn on your project? If so try:
yarn install --check-files
And please post the result of your terminal.
this my case , just remove node_modules and package-lock.json and run npm installso npm run build working correctly.show here for this answer

Karma not running in Jenkins CI, Cannot find module 'karma-jasmine'

I'm setting up an Angular 4 SPA with automatic testing in Jenkins CI. The SPA is part of a larger, Maven-managed project, so the build is also Maven-managed. So far I've:
Installed the NodeJS plugin on Jenkins, using install from nodejs.org with version 8.6.0
Configured "Global npm packages to install" = "karma-cli phantomjs-prebuilt jasmine-core karma-jasmine karma-phantomjs-launcher karma-junit-reporter karma-coverage"
Added the "maven-karma-plugin" in pom.xml with browsers=PhantomJS / singleRun=true / reporters=dots,junit
Enabled "Provide Node & npm bin/ folder to PATH" on the Jenkins job configuration
The build process starts up quite ok, but eventually I get:
[INFO] --- maven-karma-plugin:1.6:start (default) # webclient ---
[INFO] Executing Karma Test Suite ...
/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/bin/karma start /var/lib/jenkins/workspace/funnel_build/webclient/karma.conf.js --browsers PhantomJS --reporters dots,junit --single-run
07 10 2017 17:07:52.801:ERROR [config]: Error in config file!
{ Error: Cannot find module 'karma-jasmine'
at Function.Module._resolveFilename (module.js:527:15)
at Function.Module._load (module.js:476:23)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at module.exports (/var/lib/jenkins/workspace/funnel_build/webclient/karma.conf.js:9:7)
at Object.parseConfig (/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/lib/node_modules/karma/lib/config.js:410:5)
The npm install at the very beginning of the build logs:
$ /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/bin/npm install -g karma-cli phantomjs-prebuilt jasmine-core karma-jasmine karma-phantomjs-launcher karma-junit-reporter karma-coverage
/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/bin/karma -> /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/lib/node_modules/karma-cli/bin/karma
/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/bin/phantomjs -> /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/lib/node_modules/phantomjs-prebuilt/bin/phantomjs
> phantomjs-prebuilt#2.1.15 install /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/lib/node_modules/phantomjs-prebuilt
> node install.js
Considering PhantomJS found at /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/bin/phantomjs
Looks like an `npm install -g`
Could not link global install, skipping...
Download already available at /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
Verified checksum of previously downloaded file
Extracting tar contents (via spawned process)
Removing /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/lib/node_modules/phantomjs-prebuilt/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1507388835905/phantomjs-2.1.1-linux-x86_64 -> /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/lib/node_modules/phantomjs-prebuilt/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node.js_8.6.0/lib/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs
npm WARN karma-jasmine#1.1.0 requires a peer of karma#* but none was installed.
npm WARN karma-junit-reporter#1.2.0 requires a peer of karma#>=0.9 but none was installed.
npm WARN karma-phantomjs-launcher#1.0.4 requires a peer of karma#>=0.9 but none was installed.
+ karma-phantomjs-launcher#1.0.4
+ karma-coverage#1.1.1
+ karma-jasmine#1.1.0
+ karma-cli#1.0.1
+ karma-junit-reporter#1.2.0
+ jasmine-core#2.8.0
+ phantomjs-prebuilt#2.1.15
updated 7 packages in 10.553s
(The reason the package 'karma' is currently not on the list is that I read somewhere that karma-cli should be used in place of karma. Adding the 'karma' package doesn't change anything, however.)
Any idea why that "Cannot find module 'karma-jasmine'" pops up? In (2) you'll see that the karma-jasmine package is listed, I find it on the server, but still it's not found by the NodeJS plugin.
Thanks, Simon
I managed to get it to work by running "npm install" as part of the build process, and then run everything on local npm packages.
The entire setup is described here: https://funneltravel.wordpress.com/2017/10/16/running-karma-with-maven-on-jenkins-ci/

JHipster - generator give 'Unexpected token' error?

Trying to generate a clean jhipster project on a linux mint env
yo jhipster
gives
/home/poc/node_modules/generator-jhipster/generators/app/index.js:15
constructor: function (...args) { // eslint-disable-line object-shorthand
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.defineProperty.get [as jhipster:app] (/usr/local/lib/node_modules/yo/node_modules/yeoman-environment/lib/store.js:40:23)
at Store.get (/usr/local/lib/node_modules/yo/node_modules/yeoman-environment/lib/store.js:64:35)
at Environment.get (/usr/local/lib/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:262:16)
My
yo doctor
gives
Yeoman Doctor
Running sanity checks on your system
✔ Global configuration file is valid
✔ NODE_PATH matches the npm root
✔ Node.js version
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✔ npm version
I'm running these versions
nodejs - v4.2.6
npm - 3.5.2
yo - 1.8.5
Any thoughts?
Your NodeJS is too old, JHipster 4 requires 6.9.5, please upgrade node.

Executing Bower in a CI Environment, such as Jenkins

My Jenkins is running on CentOS 6 with node.js 0.10.15 and bower 1.0.3.
I have a shell task which executes the following:
npm install
bower install
grunt clean package
The bower installation fails when building:
+ bower install
path.js:360
throw new TypeError('Arguments to path.join must be strings');
^
TypeError: Arguments to path.join must be strings
at path.js:360:15
at Array.filter (native)
at Object.exports.join (path.js:358:36)
at Object.<anonymous> (/usr/lib/node_modules/bower/node_modules/
update-notifier/node_modules/configstore/configstore.js:9:7)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
Build step 'Execute shell' marked build as failure
When I'm executing bower install in a terminal while logged in as the Jenkins user, it works. The other mentioned commands work as expected (npm, grunt).
Any ideas?
It appears that your execution environment has neither $XDG_CONFIG_HOME nor $HOME set as environment variables.
You can work around this by manually setting it, for example, to the current workspace:
export XDG_CONFIG_HOME="$WORKSPACE/.config"
...
bower install

Resources