Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with nodemon #50

Open
wyckster opened this issue Sep 20, 2021 · 5 comments
Open

Doesn't work with nodemon #50

wyckster opened this issue Sep 20, 2021 · 5 comments

Comments

@wyckster
Copy link

Steps to reproduce

app.js

console.log(require('prompt-sync')()('Enter anything: '));

To run:

nodemon app.js

This app doesn't exit.

Expected output:

Enter anything: a
a
[nodemon] clean exit - waiting for changes before restart

Actual output:

Enter anything: a
Enter anything: a
                   b
Enter anything: a
b
                      c
Enter anything: a
b
c

But running directly in node works correctly:

node app.js
  • Winver: Window 10 20H2 OS Build 19042.1237
  • nodemon --version 2.0.7
  • node --version v14.15.4
@seanmcclory
Copy link

+1

@jalder89
Copy link

I've noticed an issue with the package not working in nodemon as well. However, I get an error regarding index.js in the prompt-sync package, which causes the app to crash and then nodemon monitors like normal. I don't get the hang where input is prompted, mine crashes before the prompt is displayed.

Usage

I'm requiring the package in my input.js file and then using prompt inside of an arrow function, like this:

const prompt = require('prompt-sync')()

const getInput = (callback) => {

    let input = prompt('Please enter your location: ')

    callback(input)
}

I then call getInput like this:

const input = require('./input')
input.getInput((input) => { doSomething}

Error

When running with nodemon, I get this error and stack trace:

/Users/wbarnes/Documents/Software Development/Node/Node-Course/weather-app/node_modules/prompt-sync/index.js:68
    if (!wasRaw) { process.stdin.setRawMode(true); } 

TypeError: process.stdin.setRawMode is not a function
    at prompt (/Users/wbarnes/Documents/Software Development/Node/Node-Course/weather-app/node_modules/prompt-sync/index.js:68:34)
    at Object.getInput (/Users/wbarnes/Documents/Software Development/Node/Node-Course/weather-app/input.js:6:17)

Tests

If I comment out prompt('Please enter your location: ') nodemon works without issues.

When running the app using node, the app works fine and no errors are presented. I receive the prompt in the CL as expected and then doSomething.

Version

  • MacOS: BigSur 11.6
  • nodemon --version 2.0.13
  • node --version v16.11.0

@ahmadalzoubi13579
Copy link

@wyckster any update ?

@smkun
Copy link

smkun commented Apr 25, 2024

this issue is still happening

@smkun
Copy link

smkun commented Apr 25, 2024

Here is a work around that works.
create a nodemon.json folder with this code

{ "stdin": false }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants