0

I'm coding a project in node.js on vs code and need an user input for various functions. I tried many libraries such as readline-sync or prompt-sync-plus but none of them work for me. While using readline-sync I always get the error: Process exited with code 134 and can't figure out what I'm doing wrong:

import readlineSync from 'readline-sync';
const name = readlineSync.question("Whats the name of the movie?")
console.log(name)


"Error: Process exited with code 134"

Can someone help me?

I tried to update node.js and readline-sync but it wont help. I also tried the readlineSync.question function in a different file so that I can exclude my code from the equation but its still not working

Adrian
  • 1
  • 2
  • 1
    The question should be updated to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. – Lawrence Cherone Feb 06 '23 at 15:01
  • It seems to be a known bug of `readline-sync`. But the project seem to be unmaintained since abot 4 years. Is there a reason why you don't the promise based [`readline`](https://nodejs.org/api/readline.html) that is part of nodejs? – t.niese Feb 06 '23 at 21:02

2 Answers2

0

The readline-sync library provides a synchronous interface to read data from a readable stream. When using this library in a Node.js project, you may encounter a Process exited with code 134 error, which usually indicates a problem with the process running in the background.

Try to run this code separately and see if it works.

const readlineSync = require('readline-sync');

const name = readlineSync.question('What is your name? ');
console.log(`Hello, ${name}!`);
Nafiz Ahmed
  • 23
  • 1
  • 6
-1

try using the built-in process.argv

https://nodejs.org/docs/latest/api/process.html#processargv

--> const userInput = process.argv.slice(number);

the number should be the number of arguments to be sliced off

--> node run myApplication "input1" --> number = 2

  • And how can i use this property to get an user input that I can store in a variable and use in my project? – Adrian Feb 06 '23 at 15:14