Support Forums

Some files missing after CLI deploy

I am deploying a site via CLI and some of the function files are not appearing in the target site, even though there are no deploy errors. (See GitHub Action screenshot).

I verified the files are in the source deploy directory (See GitHub Action screenshot).

I then listed the directory on Netlify and 1 module is missing. (See Netlify logs 3 screenshots note getBoardItems.js is not in the array of files returned by fs.readFileSync. See also screenshot of debug test code).

I’ve tried renaming the file and it’s the same issue.

I checked Netlify status page and there are no incidents reported.

Why are some files not being deployed?

Hi, @mjgs. Our support team would be happy to take a look a this. However, the screenshots are not ideal. Would you be willing to post the deploy logs here as text, not as images?

Also, if you would send us the deploy id (or a link to the deploy logs at Netlify) that will also help us to troubleshoot.

Without seeing that information my best guess is that the additional files are not being bundled with the function file itself. There is a section in our documentation about bundling functions here:


And CLI specific function bundling information here:


From what I can see in the screenshots, the missing files are not defined as dependencies in the function code. You will need to require them before they will be automatically bundled.

If there are other questions, please let us know.

Not Deployed Properly.

Hi @luke thanks for the reply.

In the code snippet you can see the require, it’s below the test code. I had to put the test code there because the require statement was erroring.

It looks a bit weird because I made a copy of the require function because originally I was getting a strange syntax error (it was something like “unexpected :” which was odd because there were no : characters there. I located where it was happening using console log statements. When I required using the copy of the require function, the error changed to a file not found.

There is a require of the same module in another file in the project, so I would expect the bundler to still see the file, include and deploy it.

Is there a way I can send you and your team the project link privately?

You can post that information publicly or you can private message (PM) that to one of our support staff. I’ve confirmed that PMs are enabled for your forum login. Please keep in mind that only one person can see the PM and this will likely mean a slower reply than posting the information publicly. Please feel free to reply to however you prefer though.

The site name is f6m1

Thanks for sending that, @mjgs. I’m not seeing those errors in the logging anywhere. Where can I see those errors? Even better, how do I call the function myself in a way that will trigger that error?

The screenshot never shows you calling require on that file. I see you using oldrequire to require the file and I think that is the root cause. I don’t think our function bundling recognized that as a real require statement and that is why the bundling isn’t working.

You would you try requiring the file using require itself?

I’m requiring it in another file, won’t that ensure it gets bundled?

Hi, @mjgs. That depends on the dependency tree and how you required each file. Without seeing your source files and based only on the information in the screenshot by best guess is that, no, with the current methods you are using to require files they would not be bundled correctly.

Would you be willing to link us to the repo (a public repo) or send the full source code for the all the functions you are asking about?

Hi @luke - I tried to comment out the oldrequire line and the file got included again but it’s back to the previous error.

Netlify logs:

12:50:47 PM: 2021-07-01T05:50:47.911Z undefined INFO __dirname: /var/task/dist/functions/common/utils/company
12:50:47 PM: 2021-07-01T05:50:47.923Z undefined INFO dirOfFileToRequire: /var/task/dist/functions/common/adapters/monday
12:50:47 PM: 2021-07-01T05:50:47.925Z undefined INFO [
12:50:47 PM: 2021-07-01T05:50:47.926Z undefined ERROR Uncaught Exception {“errorType”:“Runtime.UserCodeSyntaxError”,“errorMessage”:“SyntaxError: Unexpected token ‘:’”,“stack”:[“Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token ‘:’”," at _loadUserApp (/var/runtime/UserFunction.js:98:13)"," at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)"," at Object. (/var/runtime/index.js:43:30)"," at Module._compile (internal/modules/cjs/loader.js:999:30)"," at Object.Module._extensions…js (internal/modules/cjs/loader.js:1027:10)"," at Module.load (internal/modules/cjs/loader.js:863:32)"," at Function.Module._load (internal/modules/cjs/loader.js:708:14)"," at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)"," at internal/main/run_main_module.js:17:47"]}

The code that produced the error:

debug(‘loading util’);

const oldrequire = require;

const cfg = require(’…/…/config’);


const fs = require(‘fs’);
const path = require(‘path’);
console.log(__dirname: ${__dirname});
const dirOfFileToRequire = path.join(__dirname, ‘…’, ‘…’, ‘adapters’, ‘monday’);
console.log(dirOfFileToRequire: ${dirOfFileToRequire});
const files = fs.readdirSync(dirOfFileToRequire);

//const getBoardItems = oldrequire(’…/…/adapters/monday/getBoardItems’);
const getBoardItems = require(’…/…/adapters/monday/getBoardItems’);


Hey there! I can see that the f6m1 site has been deployed a lot today!

Are you still struggling with this, at all? I’m a little bit late to the party and I’m struggling to match the issue with any of the 3 functions in deployment.

Hi @Scott - thanks for taking the time to look at the issue. Yes there have been several deploys, it’s the staging site, and I’m working on another feature that has to be done in the next few days.

Are you ok to wait until next week?