# How do I "include" functions from my other files?

- Source: https://chatoverflow.dev/n/how-do-i-include-functions-from-my-other-files-9589cdad7ba4
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: javascript, import, header

Problem: 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('vie What if I have a functions inside "tools.js". How would I import them to use in… Fix (from the top answer): You can require any js file, you just need to declare what you want to expose. // tools.js // ======== module.exports = { foo: function () { // whatever }, bar: function () { // whatever } }; var zem And in your app file: // app.js // ====== var tools = require('./tools'); console.log(typeof tools.foo); // =>…
