parse-dashboard icon indicating copy to clipboard operation
parse-dashboard copied to clipboard

Impossible to generate MFA with parse-dashboard --createMFA (parse dashboard 7.1.0)

Open n3me5is-git opened this issue 7 months ago • 4 comments

New Issue Checklist

Issue Description

When running the command parse-dashboard --createMFA I obtain an error about inquirer package. I'm using Node 22 and latest parse dashboard.

$ ./node_modules/parse-dashboard/bin/parse-dashboard --createMFA

/home/node/app/node_modules/parse-dashboard/Parse-Dashboard/CLI/mfa.js:211
    const { username, app } = await inquirer.prompt([
                                             ^

TypeError: inquirer.prompt is not a function
    at createMFA (/home/node/app/node_modules/parse-dashboard/Parse-Dashboard/CLI/mfa.js:211:46)
    at Command.<anonymous> (/home/node/app/node_modules/parse-dashboard/Parse-Dashboard/index.js:38:13)
    at Command.listener [as _actionHandler] (/home/node/app/node_modules/commander/lib/command.js:482:17)
    at /home/node/app/node_modules/commander/lib/command.js:1265:65
    at Command._chainOrCall (/home/node/app/node_modules/commander/lib/command.js:1159:12)
    at Command._parseCommand (/home/node/app/node_modules/commander/lib/command.js:1265:27)
    at Command.parseAsync (/home/node/app/node_modules/commander/lib/command.js:917:16)
    at run (/home/node/app/node_modules/parse-dashboard/Parse-Dashboard/index.js:45:17)
    at Object.<anonymous> (/home/node/app/node_modules/parse-dashboard/Parse-Dashboard/index.js:51:1)
    at Module._compile (node:internal/modules/cjs/loader:1730:14)

Steps to reproduce

Run the command

Actual Outcome

The error described

Expected Outcome

Working procedure to create MFA key

Environment

Current dependencies (Node 22):

$ npm ls inquirer
[email protected] /home/node/app
`-- [email protected]
  `-- [email protected]

n3me5is-git avatar May 21 '25 20:05 n3me5is-git

🚀 Thanks for opening this issue!

ℹ️ You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

For now i'm ovverriding it in the package.json

  "overrides": {
    "parse-dashboard": {
      "inquirer": "8.2.4"
    }
  },

Probably the fix is changing the way inquirer is imported.

n3me5is-git avatar May 21 '25 20:05 n3me5is-git

Interesting find, would you want to try and open a PR, so we can see whether that fixes the issue?

mtrezza avatar May 24 '25 22:05 mtrezza

References: https://github.com/SBoudrias/Inquirer.js/releases/tag/inquirer%409.0.0

Inquirer is now a native Node ECMAScript module. This will require your Node runtime to support es modules, and your app to be an es module. Node documentation over here: https://nodejs.org/api/esm.html#modules-ecmascript-modules

If you cannot migrate, please remember you can keep using the v8.x release line until you're ready.

I don't have time to test it, but the quicker fix is to lock the inquirer version (eg. "inquirer": "8.2.4") so when installing the dependencies the override won't be needed (tested working).

A possible fix (to be tested) could be also to try import the module using const inquirer = require('inquirer').default; in the Parse-Dashboard/CLI/mfa.js file.

Since inquirer is used only for CLI utils, not a core module, using an older version is not problem and the first proposal could be the way to go.

n3me5is-git avatar May 26 '25 13:05 n3me5is-git