help icon indicating copy to clipboard operation
help copied to clipboard

Error: ENXIO: no such device or address, open '/dev/stdin'

Open N1koDev opened this issue 3 years ago • 8 comments

Details

When executing a code even though it is simple like this, the following error appears.

Node.js version

nodejs-1:16.14.0-2

Example code

const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const [tempoGasto, velocidadeMedia] = input.split("\n");

const totalPercorrido =tempoGasto * velocidadeMedia;
const qtdCombustivelGasto = totalPercorrido / 12

console.log(qtdCombustivelGasto.toFixed)

Operating system

Fedora Linux 36

Scope

node:internal/fs/utils:344
    throw err;
    ^

Error: ENXIO: no such device or address, open '/dev/stdin'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at Object.<anonymous> (/home/Golpe_Baixo/Downloads/beecrowd/javascript/1001 - Extremely Basic.js:6:29)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  errno: -6,
  syscall: 'open',
  code: 'ENXIO',
  path: '/dev/stdin'
}

Module and version

Not applicable.

N1koDev avatar Jul 09 '22 16:07 N1koDev

hey how to solve this issue...

Jaseel-Thalikulam avatar Jan 10 '23 05:01 Jaseel-Thalikulam

@NicolasSSantos @Jaseel56789 - are you running the code in a container? if so, how are you starting the container? if not, can you paste here the output of ls -lrt /dev/stdin ?

gireeshpunathil avatar Jan 10 '23 05:01 gireeshpunathil

Hey, I've the same problem. What do I have to do? image

PedroLSF avatar Mar 03 '23 04:03 PedroLSF

Hey, did anyone get round to a possible resolution? I'm still puling my hair out. I've got exactly the same issue, I am stuck.

marhtt avatar Mar 31 '23 12:03 marhtt

Hey, I've the same problem. What do I have to do? image

did you find out the fix???? i am using linux-mint and i'm stuck on it for weeks

ghost avatar Aug 30 '23 05:08 ghost

can anyone with this issue confirm if you are running in a container that is started without -it (in case of docker) flag?

gireeshpunathil avatar Aug 30 '23 06:08 gireeshpunathil

Was not able to reproduce on kali linux 2022.1 and slackware 15 on virtualbox

@NicolasSSantos @PedroLSF @marhtt can you share the output of ls -lrt /dev/stdin as suggested by @gireeshpunathil

preveen-stack avatar Aug 30 '23 07:08 preveen-stack

I am Facing the same issue but, when I tried to run the JS Code directly in the terminal or command prompt using the code:- node file_location_of_your_js_file (example:- node index.js) it works but if you are asking for the VS code then I don't know. But try the terminal trick it will work for sure.

lakshya-sharmaa avatar Feb 22 '24 07:02 lakshya-sharmaa

I am Facing the same issue but, when I tried to run the JS Code directly in the terminal or command prompt using the code:- node file_location_of_your_js_file (example:- node index.js) it works but if you are asking for the VS code then I don't know. But try the terminal trick it will work for sure.

codezaryan avatar Apr 01 '24 15:04 codezaryan

ls -lrt /dev/stdin outputs /dev/stdin -> /proc/self/fd/0

Also, can confirm, running in Kubernetes with stdin: true and tty: true

chrisvander avatar Apr 19 '24 16:04 chrisvander