I'm learning nodejs(and I like it!). I tried to figure out how to have shorter alias for console.log and I found out that I can use var cout=console.log and use cout('[string]') from then on. Then when I wanted to use process.stdout.write and I tried to make a short alias for it too, using var out=process.stdout.write. But when I use out('[string]'), I get the following error:
_stream_writable.js:220 var state = this._writableState; ^ TypeError: Cannot read property '_writableState' of undefined
at Writable.write (_stream_writable.js:220:19) at Socket.write (net.js:670:40) at Object. (/home/shayan/Desktop/nodejs/server.js:12:1)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.runMain (module.js:605:10) at run (bootstrap_node.js:423:7)
What is wrong here? How can I correctly create a short alias for process.stdout.write? Thanks
via Credo
No comments:
Post a Comment