staticrypt (cryptojs) fails inside Docker container on github actions – yargs error

  cryptojs, docker, github-actions, node.js

I’m running the staticrypt CLI (based on cryptojs) in a Docker container on Github Actions and getting an error that I can’t reproduce in my development environment. When the container runs staticrypt my_input.html password -o my_output.html, I get:

/usr/local/lib/node_modules/staticrypt/node_modules/yargs/build/index.cjs:1
"use strict";var t=require("assert");class e extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace(this,e)}}let s,i=[];function n(t,o,a,h){s=h;let l={};if(Object.prototype.hasOwnProperty.call(t,"extends")){if("string"!=typeof t.extends)return l;const r=/.json|..*rc$/.test(t.extends);let h=null;if(r)h=function(t,e){return s.path.resolve(t,e)}(o,t.extends);else try{h=require.resolve(t.extends)}catch(e){return t}!function(t){if(i.indexOf(t)>-1)throw new e(`Circular extended configurations: '${t}'.`)}(h),i.push(h),l=r?JSON.parse(s.readFileSync(h,"utf8")):require(t.extends),delete t.extends,l=n(l,s.path.dirname(h),a,s)}return i=[],a?r(l,t):Object.assign({},l,t)}function r(t,e){const s={};function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}Object.assign(s,t);for(const n of Object.keys(e))i(e[n])&&i(s[n])?s[n]=r(t[n],e[n]):s[n]=e[n];return s}function o(t){const e=t.replace(/s{2,}/g," "

Error: yargs supports a minimum Node.js version of 12. Read our version support policy: https://github.com/yargs/yargs#supported-nodejs-versions
    at Object.<anonymous> (/usr/local/lib/node_modules/staticrypt/node_modules/yargs/build/index.cjs:1:59111)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/staticrypt/node_modules/yargs/index.cjs:5:30)
    at Module._compile (internal/modules/cjs/loader.js:778:30)

The portion of the Dockerfile that pertains to node and staticrypt builds without error:

# install staticrypt
RUN apt-get update && apt-get upgrade -y && 
    apt-get install -y nodejs 
    npm
RUN npm install -g staticrypt

My repo is online here and an example of the error in the workflow is here.

Source: Docker Questions

LEAVE A COMMENT