SBoudrias / Inquirer.js

A collection of common interactive command line user interfaces.
MIT License
20.22k stars 1.3k forks source link

bug - TypeError: Cannot read property 'setRawMode' of null #565

Closed ORESoftware closed 1 year ago

ORESoftware commented 7 years ago

I reported this to Vorpal, which uses Inquirer, but I assume I should have reported it here.

https://github.com/dthree/vorpal/issues/265

Looks like Vorpal uses Inquirer underneath the hood

I see this error when using Vorpal

 TypeError: Cannot read property 'setRawMode' of null
    at ReadStream.setRawMode (tty.js:38:15)
    at Interface._setRawMode (readline.js:191:16)
    at Interface.close (readline.js:308:10)
    at UI.close (/Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman-d/node_modules/inquirer/lib/ui/baseUI.js:54:11)
    at UI.onForceClose (/Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman-d/node_modules/inquirer/lib/ui/baseUI.js:34:8)
    at emitOne (events.js:101:20)
    at process.emit (events.js:188:7)

if you want more info, lmk, thanks

ORESoftware commented 7 years ago

So I think that Vorpal is using a very old version of Inquirer

I looked into the node_modules dir, this is the package.json file for Inquirer

{
  "_args": [
    [
      {
        "raw": "inquirer@0.11.0",
        "scope": null,
        "escapedName": "inquirer",
        "name": "inquirer",
        "rawSpec": "0.11.0",
        "spec": "0.11.0",
        "type": "version"
      },
      "/Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman-d/node_modules/vorpal"
    ]
  ],
  "_from": "inquirer@0.11.0",
  "_id": "inquirer@0.11.0",
  "_inCache": true,
  "_location": "/inquirer",
  "_nodeVersion": "0.12.7",
  "_npmUser": {
    "name": "sboudrias",
    "email": "admin@simonboudrias.com"
  },
  "_npmVersion": "2.14.2",
  "_phantomChildren": {},
  "_requested": {
    "raw": "inquirer@0.11.0",
    "scope": null,
    "escapedName": "inquirer",
    "name": "inquirer",
    "rawSpec": "0.11.0",
    "spec": "0.11.0",
    "type": "version"
  },
  "_requiredBy": [
    "/vorpal"
  ],
  "_resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.11.0.tgz",
  "_shasum": "7448bfa924092af311d47173bbab990cae2bb027",
  "_shrinkwrap": null,
  "_spec": "inquirer@0.11.0",
  "_where": "/Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman-d/node_modules/vorpal",
  "author": {
    "name": "Simon Boudrias",
    "email": "admin@simonboudrias.com"
  },
  "bugs": {
    "url": "https://github.com/SBoudrias/Inquirer.js/issues"
  },
  "dependencies": {
    "ansi-escapes": "^1.1.0",
    "ansi-regex": "^2.0.0",
    "chalk": "^1.0.0",
    "cli-cursor": "^1.0.1",
    "cli-width": "^1.0.1",
    "figures": "^1.3.5",
    "lodash": "^3.3.1",
    "readline2": "^1.0.1",
    "run-async": "^0.1.0",
    "rx-lite": "^3.1.2",
    "strip-ansi": "^3.0.0",
    "through": "^2.3.6"
  },
  "description": "A collection of common interactive command line user interfaces.",
  "devDependencies": {
    "chai": "^3.0.0",
    "cmdify": "^0.0.4",
    "grunt": "^0.4.1",
    "grunt-cli": "^0.1.8",
    "grunt-contrib-jshint": "^0.11.1",
    "grunt-mocha-test": "^0.12.7",
    "mocha": "^2.2.1",
    "mockery": "^1.4.0",
    "sinon": "^1.12.1"
  },
  "directories": {},
  "dist": {
    "shasum": "7448bfa924092af311d47173bbab990cae2bb027",
    "tarball": "https://registry.npmjs.org/inquirer/-/inquirer-0.11.0.tgz"
  },
  "files": [
    "lib"
  ],
  "gitHead": "8a7a538d365a15a9ba9a97e464a487a7d2410dc4",
  "homepage": "https://github.com/SBoudrias/Inquirer.js#readme",
  "keywords": [
    "command",
    "prompt",
    "stdin",
    "cli",
    "tty",
    "menu"
  ],
  "license": "MIT",
  "main": "lib/inquirer.js",
  "maintainers": [
    {
      "name": "sboudrias",
      "email": "admin@simonboudrias.com"
    }
  ],
  "name": "inquirer",
  "optionalDependencies": {},
  "readme": "Inquirer.js\n===========\n\n[![npm](https://badge.fury.io/js/inquirer.svg)](http://badge.fury.io/js/inquirer) [![tests](https://travis-ci.org/SBoudrias/Inquirer.js.svg?branch=master)](http://travis-ci.org/SBoudrias/Inquirer.js) [![dependencies](https://david-dm.org/SBoudrias/Inquirer.js.svg?theme=shields.io)](https://david-dm.org/SBoudrias/Inquirer.js)\n\nA collection of common interactive command line user interfaces.\n\n\n## Goal and Philosophy\n\n<img align=\"right\" alt=\"Inquirer Logo\" src=\"/assets/inquirer_readme.png\" title=\"Inquirer.js\"/>\n\n**`Inquirer.js`** strives to be an easily embeddable and beautiful command line interface for [Node.js](https://nodejs.org/) (and perhaps the \"CLI [Xanadu](https://en.wikipedia.org/wiki/Xanadu_(Citizen_Kane))\").\n\n**`Inquirer.js`** should ease the process of\n- providing *error feedback*\n- *asking questions*\n- *parsing* input\n- *validating* answers\n- managing *hierarchical prompts*\n\n> **Note:** **`Inquirer.js`** provides the user interface, and the inquiry session flow. If you're searching for a full blown command line program utility, then check out [Commander.js](https://github.com/visionmedia/commander.js).\n\n\n## Documentation\n\n### Installation\n\n``` shell\nnpm install inquirer\n```\n\n```javascript\nvar inquirer = require(\"inquirer\");\ninquirer.prompt([/* Pass your questions in here */], function( answers ) {\n\t// Use user feedback for... whatever!!\n});\n```\n\n\n### Examples (Run it and see it)\nCheckout the `examples/` folder for code and interface examples.\n\n``` shell\nnode examples/pizza.js\nnode examples/checkbox.js\n# etc...\n```\n\n\n### Methods\n\n`inquirer.prompt( questions, callback )`\n\nLaunch the prompt interface (inquiry session)\n\n- **questions** (Array) containing [Question Object](#question) (using the [reactive interface](#reactive-interface), you can also pass a `Rx.Observable` instance)\n- **callback** (Function) first parameter is the [Answers Object](#answers)\n\n\n### Objects\n\n#### Question\nA question object is a `hash` containing question related values:\n\n- **type**: (String) Type of the prompt. Defaults: `input` - Possible values: `input`, `confirm`,\n`list`, `rawlist`, `password`\n- **name**: (String) The name to use when storing the answer in the answers hash.\n- **message**: (String|Function) The question to print. If defined as a function, the first parameter will be the current inquirer session answers.\n- **default**: (String|Number|Array|Function) Default value(s) to use if nothing is entered, or a function that returns the default value(s). If defined as a function, the first parameter will be the current inquirer session answers.\n- **choices**: (Array|Function) Choices array or a function returning a choices array. If defined as a function, the first parameter will be the current inquirer session answers.  \nArray values can be simple `strings`, or `objects` containing a `name` (to display in list), a `value` (to save in the answers hash) and a `short` (to display after selection) properties. The choices array can also contain [a `Separator`](#separator).\n- **validate**: (Function) Receive the user input and should return `true` if the value is valid, and an error message (`String`) otherwise. If `false` is returned, a default error message is provided.\n- **filter**: (Function) Receive the user input and return the filtered value to be used inside the program. The value returned will be added to the _Answers_ hash.\n- **when**: (Function, Boolean) Receive the current user answers hash and should return `true` or `false` depending on whether or not this question should be asked. The value can also be a simple boolean.\n\n`default`, `choices`(if defined as functions), `validate`, `filter` and `when` functions can be called asynchronously using `this.async()`. You just have to pass the value you'd normally return to the callback option.\n\n``` javascript\n{\n  validate: function(input) {\n\n    // Declare function as asynchronous, and save the done callback\n    var done = this.async();\n\n    // Do async stuff\n    setTimeout(function() {\n      if (typeof input !== \"number\") {\n        // Pass the return value in the done callback\n        done(\"You need to provide a number\");\n        return;\n      }\n      // Pass the return value in the done callback\n      done(true);\n    }, 3000);\n  }\n}\n```\n\n### Answers\nA key/value hash containing the client answers in each prompt.\n\n- **Key** The `name` property of the _question_ object\n- **Value** (Depends on the prompt)\n  - `confirm`: (Boolean)\n  - `input` : User input (filtered if `filter` is defined) (String)\n  - `rawlist`, `list` : Selected choice value (or name if no value specified) (String)\n\n### Separator\nA separator can be added to any `choices` array:\n\n```\n// In the question object\nchoices: [ \"Choice A\", new inquirer.Separator(), \"choice B\" ]\n\n// Which'll be displayed this way\n[?] What do you want to do?\n > Order a pizza\n   Make a reservation\n   --------\n   Ask opening hours\n   Talk to the receptionist\n```\n\nThe constructor takes a facultative `String` value that'll be use as the separator. If omitted, the separator will be `--------`.\n\nSeparator instances have a property `type` equal to `separator`. This should allow tools façading Inquirer interface from detecting separator types in lists.\n\nPrompts type\n---------------------\n\n> **Note:**: _allowed options written inside square brackets (`[]`) are optional. Others are required._\n\n#### List - `{ type: \"list\" }`\n\nTake `type`, `name`, `message`, `choices`[, `default`, `filter`] properties. (Note that\ndefault must be the choice `index` in the array or a choice `value`)\n\n![List prompt](https://dl.dropboxusercontent.com/u/59696254/inquirer/list-prompt.png)\n\n---\n\n#### Raw List - `{ type: \"rawlist\" }`\n\nTake `type`, `name`, `message`, `choices`[, `default`, `filter`] properties. (Note that\ndefault must the choice `index` in the array)\n\n![Raw list prompt](https://i.cloudup.com/LcRGpXI0CX-3000x3000.png)\n\n---\n\n#### Expand - `{ type: \"expand\" }`\n\nTake `type`, `name`, `message`, `choices`[, `default`, `filter`] properties. (Note that\ndefault must be the choice `index` in the array)\n\nNote that the `choices` object will take an extra parameter called `key` for the `expand` prompt. This parameter must be a single (lowercased) character. The `h` option is added by the prompt and shouldn't be defined by the user.\n\nSee `examples/expand.js` for a running example.\n\n![Expand prompt closed](https://dl.dropboxusercontent.com/u/59696254/inquirer/expand-prompt-1.png)\n![Expand prompt expanded](https://dl.dropboxusercontent.com/u/59696254/inquirer/expand-prompt-2.png)\n\n---\n\n#### Checkbox - `{ type: \"checkbox\" }`\n\nTake `type`, `name`, `message`, `choices`[, `filter`, `validate`, `default`] properties. `default` is expected to be an Array of the checked choices value.\n\nChoices marked as `{ checked: true }` will be checked by default.\n\nChoices whose property `disabled` is truthy will be unselectable. If `disabled` is a string, then the string will be outputted next to the disabled choice, otherwise it'll default to `\"Disabled\"`. The `disabled` property can also be a synchronous function receiving the current answers as argument and returning a boolean or a string.\n\n![Checkbox prompt](https://dl.dropboxusercontent.com/u/59696254/inquirer/checkbox-prompt.png)\n\n---\n\n#### Confirm - `{ type: \"confirm\" }`\n\nTake `type`, `name`, `message`[, `default`] properties. `default` is expected to be a boolean if used.\n\n![Confirm prompt](https://dl.dropboxusercontent.com/u/59696254/inquirer/confirm-prompt.png)\n\n---\n\n#### Input - `{ type: \"input\" }`\n\nTake `type`, `name`, `message`[, `default`, `filter`, `validate`] properties.\n\n![Input prompt](https://dl.dropboxusercontent.com/u/59696254/inquirer/input-prompt.png)\n\n---\n\n#### Password - `{ type: \"password\" }`\n\nTake `type`, `name`, `message`[, `default`, `filter`, `validate`] properties.\n\n![Password prompt](https://dl.dropboxusercontent.com/u/59696254/inquirer/password-prompt.png)\n\n## User Interfaces and layouts\n\nAlong with the prompts, Inquirer offers some basic text UI.\n\n#### Bottom Bar - `inquirer.ui.BottomBar`\n\nThis UI present a fixed text at the bottom of a free text zone. This is useful to keep a message to the bottom of the screen while outputting command outputs on the higher section.\n\n```javascript\nvar ui = new inquirer.ui.BottomBar();\n\n// pipe a Stream to the log zone\noutputStream.pipe( ui.log );\n\n// Or simply write output\nui.log.write(\"something just happened.\");\nui.log.write(\"Almost over, standby!\");\n\n// During processing, update the bottom bar content to display a loader\n// or output a progress bar, etc\nui.updateBottomBar(\"new bottom bar content\");\n```\n\n#### Prompt - `inquirer.ui.Prompt`\n\nThis is UI layout used to run prompt. This layout is returned by `inquirer.prompt` and you should probably always use `inquirer.prompt` to interface with this UI.\n\n\n## Reactive interface\n\nInternally, Inquirer uses the [JS reactive extension](https://github.com/Reactive-Extensions/RxJS) to handle events and async flows.\n\nThis mean you can take advantage of this feature to provide more advanced flows. For example, you can dynamically add questions to be asked:\n\n```js\nvar prompts = Rx.Observable.create(function( obs ) {\n  obs.onNext({ /* question... */ });\n  setTimeout(function () {\n    obs.onNext({ /* question... */ });\n    obs.onCompleted();\n  });\n});\n\ninquirer.prompt(prompts);\n```\n\nAnd using the `process` property, you have access to more fine grained callbacks:\n\n```js\ninquirer.prompt(prompts).process.subscribe(\n  onEachAnswer,\n  onError,\n  onComplete\n);\n```\n\n## Support (OS Terminals)\n\nYou should expect mostly good support for the CLI below. This does not mean we won't\nlook at issues found on other command line - feel free to report any!\n\n- **Mac OS**:\n  - Terminal.app\n  - iTerm\n- **Windows**:\n  - cmd.exe\n  - Powershell\n  - Cygwin\n- **Ubuntu**:\n  - Terminal\n\n\n## News on the march (Release notes)\n\nPlease refer to the [Github releases section for the changelog](https://github.com/SBoudrias/Inquirer.js/releases)\n\n\n## Contributing\n\n**Style Guide**  \nPlease brief yourself on [Idiomatic.js](https://github.com/rwldrn/idiomatic.js) style guide with two space indent  \n\n**Unit test**  \nUnit test are written in [Mocha](http://visionmedia.github.io/mocha/). Please add a unit test for every new feature or bug fix. `npm test` to run the test suite.  \n\n**Documentation**  \nAdd documentation for every API change. Feel free to send corrections\nor better docs!  \n\n**Pull Requests**  \nSend _fixes_ PR on the `master` branch. Any new features should be send on the `wip`branch.\n\nWe're looking to offer good support for multiple prompts and environments. If you want to\nhelp, we'd like to keep a list of testers for each terminal/OS so we can contact you and\nget feedback before release. Let us know if you want to be added to the list (just tweet\nto @vaxilart) or just add your name to [the wiki](https://github.com/SBoudrias/Inquirer.js/wiki/Testers)\n\n## License\n\nCopyright (c) 2012 Simon Boudrias (twitter: @vaxilart)  \nLicensed under the MIT license.\n",
  "readmeFilename": "README.md",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/SBoudrias/Inquirer.js.git"
  },
  "scripts": {
    "test": "grunt --verbose"
  },
  "version": "0.11.0"
}