简体   繁体   English

从交互式命令行会话中保存nodejs历史记录

[英]save nodejs history from interactive command-line session

After using node in interactive/command line mode to explore, how can I copy my command history to a text file for my own future records? 在交互/命令行模式下使用node进行探索后,如何将命令历史记录复制到文本文件中以供将来使用?

The up arrow key recalls previous node statements, and furthermore already persists across logins, so the history is already being saved somewhere in node.js . 向上箭头键可以调用以前的node语句,而且已经跨登录持续存在,因此历史记录已经保存在node.js中的某个位置 But where is it saved? 但它在哪里得救了? How can I copy it? 我该如何复制?

But I could find nothing in node --help 但我在node --help找不到任何东西node --help

The read-evaluate-print-loop or REPL has a documented list of special nodejs REPL commands , including a save command: read-evaluate-print-loop或REPL有一个特殊nodejs REPL命令的文档列表 ,包括一个save命令:

 .save /path/to/save/my/history 

Also, look in ~/.node_repl_history 另外,查看~/.node_repl_history

you just need to run this command 你只需要运行这个命令

node app.js > log.txt

this command will save all command prompt output to a file 此命令将所有命令提示输出保存到文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM