node.js - 在同一个js文件node.js中调用exports.start

标签 node.js

您好,这是我在 Node js 文件中的方法:

exports.start = function() {
    console.log(' in start of sender.js');
});

如何在同一个js文件中调用这个方法?我尝试调用 start() 和 exports.start() 但不成功。

最佳答案

使用此代码:

var start = exports.start = function() {
   console.log(' in start of sender.js');
});

function start() {
   console.log(' in start of sender.js');
});

exports.start = start;

//you can call start();

关于node.js - 在同一个js文件node.js中调用exports.start,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13859404/

相关文章:

javascript - Phantom.js - 如何使用 promise 而不是回调?

javascript - 直接上传到 AWS S3 : SignatureDoesNotMatch only for IE

node.js - 如何将 websocket 二进制消息作为流发送到 Google Speech API?

node.js - 使用 Promisify(https) 的 POST 语法

javascript - 如何使用 expressjs、reactjs 持久化数据?

Javascript Electron 从列表中删除/忽略某个项目

node.js - 类型错误 : Converting circular structure to JSON when changed to NodeJS Async Await

node.js - 在 Nodejs 中生成 API key 和哈希密码的最佳方法是什么?

Linux:让服务永远运行直到我停止它? Node.js + Socket.io

javascript - 是否可以使用 Testcafé 访问网站上定义的 af 函数?