Nodejs commandline: Difference between revisions
From wikinotes
(One intermediate revision by the same user not shown) | |||
Line 28: | Line 28: | ||
</source> | </source> | ||
</blockquote><!-- stdout, stderr, stdin --> | </blockquote><!-- stdout, stderr, stdin --> | ||
= vi mode = | |||
<blockquote> | |||
<source lang="bash"> | |||
# ~/.bashrc | |||
# see https://github.com/nodejs/node/issues/5608 | |||
if [ $(command -v rlwrap) ] ; then | |||
alias node='NODE_NO_READLINE=1 rlwrap node' | |||
fi | |||
</source> | |||
</blockquote><!-- vi mode --> |
Latest revision as of 19:03, 27 September 2023
Most cli related code resides in:
Running Code
node script.js foo bar baz
Parsing Arguments
process.argv // string array of cli args process.exit(1) // exit with process exit-code
stdout, stderr, stdin
console.log('hello world') # print to stdout console.error('hello world') # print to stderr process.stdin
vi mode
# ~/.bashrc # see https://github.com/nodejs/node/issues/5608 if [ $(command -v rlwrap) ] ; then alias node='NODE_NO_READLINE=1 rlwrap node' fi