ruimarinho / gsts

Obtain and store AWS STS credentials to interact with Amazon services by authenticating via G Suite SAML.
MIT License
212 stars 37 forks source link

fix: Node 16 does not like ESM modules... #93

Closed jontg closed 9 months ago

ruimarinho commented 11 months ago

@jontg I don't know if I understand this PR correctly - wouldn't the other import directives also not working in node 16 or is there something specific to this change that fixes node 16?

jontg commented 11 months ago

When trying to use this binary in node16, you get errors to the effect of:

file:///Users/jontg/.npm/_npx/e067a5a6c2ccf460/node_modules/gsts/credentials-manager.js:11
import { chmod, mkdir, readFile, writeFile, constants } from 'node:fs/promises';
                                            ^^^^^^^^^
SyntaxError: The requested module 'node:fs/promises' does not provide an export named 'constants'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:179:5)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at async Object.loadESM (node:internal/process/esm_loader:68:5)
    at async handleMainPromise (node:internal/modules/run_main:63:12)

Take a look at, for example, this discussion

ruimarinho commented 9 months ago

Indeed, seems like I forgot to update the engines property to require node 18+ on gsts@5. Unfortunately I don't have the time to maintain node<18 so I suggesting using a node manager like volta or nvm to run gsts with a more recent version of node.