如何从命令行将脚本导入NodeJ?

the*_*art 6 shell command-line node.js

从命令行,我想从我的粘贴板(FYI:pbpaste是一个OSX功能)中获取一个脚本并将其传递到Node的repl命令行工具中.例如:

pbpaste | node -e

这不会评估剪贴板中的内容.如何让运行时执行此操作?

log*_*yth 9

-e选项用于运行作为参数传递的JS.要从stdin运行JS,您可以直接管道node.

pbpaste | node
Run Code Online (Sandbox Code Playgroud)