您如何通过命令行将脚本传递到NodeJ中? [英] How do you pipe scripts into NodeJs from command line?
本文介绍了您如何通过命令行将脚本传递到NodeJ中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从命令行,我想从粘贴板中获取脚本(仅供参考:pbpaste是OSX功能),并将其通过管道传递到Node的repl命令行工具中.例如:
From command line, I'd like to take a script from my paste board (FYI: pbpaste is an OSX feature) and pipe it into the Node's repl command line tool. For example:
<代码>pbpaste |节点-e
这不评估剪贴板中的内容.如何获得运行时来执行此操作?
This does not evaluate the contents in my clipboard. How do I get the runtime to do this?
推荐答案
-e
选项用于运行作为参数传递的JS.要从stdin运行JS,您可以直接通过管道直接连接到 node
.
The -e
option is for running JS passed as an argument. To run JS from stdin, you can simply pipe to node
directly.
pbpaste | node
这篇关于您如何通过命令行将脚本传递到NodeJ中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文