workshopper / stream-adventure

go on an educational stream adventure!
Other
2.06k stars 313 forks source link

Error running on Windows: process.stdin.setRawMode is not a function #171

Open xxnatc opened 8 years ago

xxnatc commented 8 years ago

Got stream-adventure to install, but when I try to run it I get this error:

$ stream-adventure
C:\Users\Nat\AppData\Roaming\npm\node_modules\stream-adventure\node_modules\adventure\lib\menu.js:51
    process.stdin.setRawMode(true);
                  ^

TypeError: process.stdin.setRawMode is not a function
    at module.exports (C:\Users\Nat\AppData\Roaming\npm\node_modules\stream-adventure\node_modules\adventure\lib\menu.js:51:19)
    at Shop.showMenu (C:\Users\Nat\AppData\Roaming\npm\node_modules\stream-adventure\node_modules\adventure\index.js:267:16)
    at Shop.execute (C:\Users\Nat\AppData\Roaming\npm\node_modules\stream-adventure\node_modules\adventure\index.js:131:14)
    at Object.<anonymous> (C:\Users\Nat\AppData\Roaming\npm\node_modules\stream-adventure\bin\cmd.js:18:6)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:136:18)

I'm on Win 10 with node v4.2.4. There is a similar issue (#38) but my node version should be supported.

Jim-MK commented 8 years ago

i have the same trouble .i update node version and still not work

$ stream-adventure C:\Users\Windows 8.1\AppData\Roaming\npm\node_modules\stream-adventure\node_modules\adventure\lib\menu.js:51 process.stdin.setRawMode(true); ^

TypeError: process.stdin.setRawMode is not a function at module.exports (C:\Users\Windows 8.1\AppData\Roaming\npm\node_modules\stream-adventure\node_modules\adventure\lib\menu.js:51:19) at Shop.showMenu (C:\Users\Windows 8.1\AppData\Roaming\npm\node_modules\stream-adventure\node_modules\adventure\index.js:267:16) at Shop.execute (C:\Users\Windows 8.1\AppData\Roaming\npm\node_modules\stream-adventure\node_modules\adventure\index.js:131:14) at Object. (C:\Users\Windows 8.1\AppData\Roaming\npm\node_modules\stream-adventure\bin\cmd.js:18:6) at Module._compile (module.js:413:34) at Object.Module._extensions..js (module.js:422:10) at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Function.Module.runMain (module.js:447:10) at startup (node.js:142:18)

denghongcai commented 8 years ago

node do not detect that you are running code inside tty.

When Node.js detects that it is being run inside a TTY context, then process.stdin will be a tty.ReadStream instance and process.stdout will be a tty.WriteStream instance. The preferred way to check if Node.js is being run in a TTY context is to check process.stdout.isTTY:

$ node -p -e "Boolean(process.stdout.isTTY)"
true
$ node -p -e "Boolean(process.stdout.isTTY)" | cat
false

if result is false, try to use cmd to start.

Jim-MK commented 8 years ago

ths i try $ node -p -e "Boolean(process.stdout.isTTY)" return fasle so i use cmd to start it success

ccarruitero commented 4 years ago

@xxnatc @Jim-MK Can you confirm if this was solved in recent node versions?