0
我尝试使用我的Gulpfile中另一个Javascript文件中的函数,但无法使其工作到目前为止。无法在Gulpfile中导入JavaScript文件
的文件,我需要在Gulpfile访问:
var hello = function(){
console.log('Hello')
}
而且我需要在我的Gulpfile方式:
var tools = require('./public/js/tools.js');
gulp.task('create_subscriptions', function(){
tools.hello();
});
tools.hello() is not a function
被触发。
我在这里做错了什么?
编辑
我做
module.exports = {
hello: hello()
};
请告诉我差机智exports.hello = hello
?
[Node.js module.exports的用途和你如何使用它的目的是什么?](http://stackoverflow.com/questions/5311334/what-is-the-purpose-of-node -js-module-exports-how-do-you-use-it) –
除非你返回一个新函数,否则你应该删除'()'。所以,'hello:hello' – Roberto14