Quantcast
Channel: Active questions tagged header - Stack Overflow
Viewing all articles
Browse latest Browse all 705

In Node.js, how do I "include" functions from my other files?

$
0
0

Let's say I have a file called app.js. Pretty simple:

var express = require('express');var app = express.createServer();app.set('views', __dirname +'/views');app.set('view engine', 'ejs');app.get('/', function(req, res){  res.render('index', {locals: {    title: 'NowJS + Express Example'  }});});app.listen(8080);

What if I have a functions inside "tools.js". How would I import them to use in apps.js?

Or...am I supposed to turn "tools" into a module, and then require it? << seems hard, I rather do the basic import of the tools.js file.


Viewing all articles
Browse latest Browse all 705

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>