gpt4 book ai didi

node.js - 如何为 Node 设置预加载文件?

转载 作者:搜寻专家 更新时间:2023-10-31 22:58:36 25 4
gpt4 key购买 nike

有没有办法在我每次运行node(交互式)之前预加载一些文件,就像.vimrc.bash_profile,等等?

我主要以交互方式使用node,我经常使用模块CSV,有没有办法避免输入require('./csv') 每次启动 node?

最佳答案

创建初始化文件(例如~/.noderc):

var csv = require('csv');

// put a blank line at the end of the file

现在将此行添加到您的 shell 配置(.bashrc/.zshrc/无论您使用什么 shell):

alias nodei="cat ~/.noderc - | node -i"

瞧!

关于node.js - 如何为 Node 设置预加载文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23036753/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com