My utility modules located in netlify/functions/utils/ are not being included in the deploy bundle. I added them to netlify.toml and I’m calling them from a function using relative path
const { estimateTokens, selectRelevantEntries, selectAppropriateModel } = require(‘./utils/tokenManagement’);
The utility file is called tokenManagement.js
12:46:18 PM: build-image version: c38927cce92092afc316743af1f8656a643fa4a5 (noble)
12:46:18 PM: buildbot version: 766d2c1ac7b7596f18b546cb6bf13962d157b033
12:46:19 PM: Fetching cached dependencies
12:46:19 PM: Starting to download cache of 507.9MB
12:46:20 PM: Finished downloading cache in 1.593s
12:46:20 PM: Starting to extract cache
12:46:24 PM: Finished extracting cache in 3.482s
12:46:24 PM: Finished fetching cache in 5.17s
12:46:24 PM: Starting to prepare the repo for build
12:46:24 PM: Preparing Git Reference refs/heads/main
12:46:26 PM: Custom functions path detected. Proceeding with the specified path: ‘netlify/functions’
12:46:26 PM: Starting to install dependencies
12:46:27 PM: Started restoring cached mise cache
12:46:28 PM: Finished restoring cached mise cache
12:46:28 PM: Python version set to 3.13.3
12:46:28 PM: Ruby version set to 2.7.2
12:46:28 PM: Go version set to 1.19
12:46:29 PM: Using PHP version 8.3
12:46:30 PM: Started restoring cached Node.js version
12:46:31 PM: Finished restoring cached Node.js version
12:46:31 PM: v22.15.0 is already installed.
12:46:31 PM: Now using node v22.15.0 (npm v10.9.2)
12:46:31 PM: Enabling Node.js Corepack
12:46:32 PM: Started restoring cached build plugins
12:46:32 PM: Finished restoring cached build plugins
12:46:32 PM: Started restoring cached corepack dependencies
12:46:32 PM: Finished restoring cached corepack dependencies
12:46:32 PM: No npm workspaces detected
12:46:32 PM: Started restoring cached node modules
12:46:32 PM: Finished restoring cached node modules
12:46:32 PM: Installing npm packages using npm version 10.9.2
12:46:33 PM: up to date, audited 225 packages in 778ms
12:46:33 PM: 41 packages are looking for funding
12:46:33 PM: run npm fund
for details
12:46:33 PM: 3 vulnerabilities (1 moderate, 2 high)
12:46:33 PM: To address issues that do not require attention, run:
12:46:33 PM: npm audit fix
12:46:33 PM: To address all issues (including breaking changes), run:
12:46:33 PM: npm audit fix --force
12:46:33 PM: Run npm audit
for details.
12:46:33 PM: npm packages installed
12:46:33 PM: Successfully installed dependencies
12:46:33 PM: Starting build script
12:46:34 PM: Detected 1 framework(s)
12:46:34 PM: “vite” at version “6.2.3”
12:46:34 PM: Section completed: initializing
12:46:35 PM:
12:46:35 PM: Netlify Build
12:46:35 PM: ────────────────────────────────────────────────────────────────
12:46:35 PM:
12:46:35 PM: ❯ Version
12:46:35 PM: @netlify/build 32.1.0
12:46:35 PM:
12:46:35 PM: ❯ Flags
12:46:35 PM: accountId: 67e295fe2bda2900864d0cd7
12:46:35 PM: baseRelDir: true
12:46:35 PM: buildId: 681253ce6b9caa0008f118de
12:46:35 PM: deployId: 681253ce6b9caa0008f118e0
12:46:36 PM:
12:46:36 PM: ❯ Current directory
12:46:36 PM: /opt/build/repo
12:46:36 PM:
12:46:36 PM: ❯ Config file
12:46:36 PM: /opt/build/repo/netlify.toml
12:46:36 PM:
12:46:36 PM: ❯ Context
12:46:36 PM: production
12:46:36 PM:
12:46:36 PM: Build command from Netlify app
12:46:36 PM: ────────────────────────────────────────────────────────────────
12:46:36 PM:
12:46:36 PM: $ npm run build
12:46:36 PM: > aimyref@1.0.0 build
12:46:36 PM: > vite build
12:46:36 PM: vite v6.2.3 building for production…
12:46:36 PM: transforming…
12:46:38 PM: ✓ 124 modules transformed.
12:46:38 PM: rendering chunks…
12:46:38 PM: computing gzip size…
12:46:38 PM: dist/index.html 0.44 kB │ gzip: 0.29 kB
12:46:38 PM: dist/assets/index-BX_rl2tX.css 27.53 kB │ gzip: 5.39 kB
12:46:38 PM: dist/assets/browser-DdW20ack.js 0.34 kB │ gzip: 0.27 kB
12:46:38 PM: dist/assets/index-C2RwxSDY.js 407.05 kB │ gzip: 116.19 kB
12:46:38 PM: ✓ built in 1.99s
12:46:38 PM:
12:46:38 PM: (build.command completed in 2.4s)
12:46:38 PM:
12:46:38 PM: Functions bundling
12:46:38 PM: ────────────────────────────────────────────────────────────────
12:46:38 PM:
12:46:38 PM: Packaging Functions from netlify/functions directory:
12:46:38 PM: - analyze.js
12:46:38 PM: - approveWaitlistedUser.js
12:46:38 PM: - createUser.js
12:46:38 PM: - diagnosticSql.js
12:46:38 PM: - directSqlUpdate.js
12:46:38 PM: - fetchEntry.js
12:46:38 PM: - finalUpdateEntry.js
12:46:38 PM: - followupAnalyze.js
12:46:38 PM: - getTopics.js
12:46:38 PM: - inviteUser.js
12:46:38 PM: - joinWaitlist.js
12:46:38 PM: - processTopicRequest.js
12:46:38 PM: - requestCustomTopic.js
12:46:38 PM: - resendInvitation.js
12:46:38 PM: - resetPassword.js
12:46:38 PM: - simpleUpdate.js
12:46:38 PM: - submitJournalEntry.js
12:46:38 PM: - testPasswordReset.js
12:46:38 PM: - updateJournalEntry.js
12:46:38 PM:
12:46:43 PM:
12:46:43 PM: (Functions bundling completed in 4.8s)
12:46:43 PM:
12:46:43 PM: Deploy site
12:46:43 PM: ────────────────────────────────────────────────────────────────
12:46:43 PM:
12:46:43 PM: Starting to deploy site from ‘dist’
12:46:43 PM: Calculating files to upload
12:46:44 PM: 0 new file(s) to upload
12:46:44 PM: 1 new function(s) to upload
12:46:50 PM: Starting post processing
12:46:50 PM: Section completed: deploying
12:46:50 PM: Site deploy was successfully initiated
12:46:50 PM:
12:46:50 PM: (Deploy site completed in 7.3s)
12:46:50 PM:
12:46:50 PM: Netlify Build Complete
12:46:50 PM: ────────────────────────────────────────────────────────────────
12:46:50 PM:
12:46:50 PM: (Netlify Build completed in 14.6s)
12:46:51 PM: Post processing - header rules
12:46:51 PM: Post processing done
12:46:51 PM: Section completed: postprocessing
12:46:51 PM: Skipping form detection
12:46:51 PM: Post processing - redirect rules
12:46:51 PM: Caching artifacts
12:46:51 PM: Started saving node modules
12:46:51 PM: Finished saving node modules
12:46:51 PM: Started saving build plugins
12:46:51 PM: Finished saving build plugins
12:46:51 PM: Started saving mise cache
12:46:51 PM: Finished saving mise cache
12:46:51 PM: Started saving corepack cache
12:46:51 PM: Finished saving corepack cache
12:46:51 PM: Started saving emacs cask dependencies
12:46:51 PM: Finished saving emacs cask dependencies
12:46:51 PM: Started saving maven dependencies
12:46:51 PM: Finished saving maven dependencies
12:46:51 PM: Started saving boot dependencies
12:46:51 PM: Finished saving boot dependencies
12:46:51 PM: Started saving rust rustup cache
12:46:51 PM: Finished saving rust rustup cache
12:46:51 PM: Build script success
12:46:51 PM: Section completed: building
12:46:52 PM: Site is live
12:46:53 PM: Uploading Cache of size 507.9MB
12:46:55 PM: Section completed: cleanup
12:46:55 PM: Finished processing build request in 36.023s
Your repo is private.
Thanks for getting back to me @hrishikesh. I can share my repo with you if that would help? Please let me know your ID.
The line in the function calling the file in utils: const { estimateTokens, selectRelevantEntries, selectAppropriateModel } = require(‘./utils/tokenManagement’);
The .toml file saved in root of main branch:
[functions]
included_files = [“netlify/functions/utils/**”]
[functions.analyze]
included_files = [“netlify/functions/utils/tokenManagement.js”]
Hi, @gbornstein. Looking at the require
it is using the relative directory utils
before tokenManagement
.
However, the include in for the files in utils
but that would imply that the directory itself is not being bundled. So instead of this:
require(‘./utils/tokenManagement’);
Maybe try it without the utils
directory like so instead:
require(‘./tokenManagement’);
Would you please test that and let us know the results?