Open wyckster opened 2 years ago
+1
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.
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}
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)
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.
@wyckster any update ?
this issue is still happening
Here is a work around that works. create a nodemon.json folder with this code
{ "stdin": false }
Steps to reproduce
app.js
To run:
This app doesn't exit.
Expected output:
Actual output:
But running directly in node works correctly:
nodemon --version
2.0.7node --version
v14.15.4