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

How do I get stdin input with javascript? #30

Open
wildcatco opened this issue Feb 17, 2023 · 0 comments
Open

How do I get stdin input with javascript? #30

wildcatco opened this issue Feb 17, 2023 · 0 comments

Comments

@wildcatco
Copy link

const input = require('fs').readFileSync('/dev/stdin').toString().split(' ');
console.log(Number(input[0]) + Number(input[1]));

With this code, I get error
"node:internal/fs/utils:344\n throw err;\n ^\n\nError: ENXIO: no such device or address, open '/dev/stdin'\n at Object.openSync (node:fs:585:3)\n at Object.readFileSync (node:fs:453:35)\n at Object. (/app/codes/10609b19-df6a-4e33-8cc6-f31183eb3f29.js:1:29)\n at Module._compile (node:internal/modules/cjs/loader:1101:14)\n at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)\n at Module.load (node:internal/modules/cjs/loader:981:32)\n at Function.Module._load (node:internal/modules/cjs/loader:822:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)\n at node:internal/main/run_main_module:17:47 {\n errno: -6,\n syscall: 'open',\n code: 'ENXIO',\n path: '/dev/stdin'\n}\n"

How can i access to stdin in javascript?

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

1 participant