Error - ENOENT: no such file or directory, open '/var/task/netlify/functions/bridge.js'
Stack trace
Error: ENOENT: no such file or directory, open '/var/task/netlify/functions/bridge.js'
at Object.openSync (node:fs:590:3)
at Object.readFileSync (node:fs:458:35)
at node_modules/vm2/lib/vm.js (/var/task/netlify/functions/demo.js:74426:122)
at __require (/var/task/netlify/functions/demo.js:22:50)
at node_modules/vm2/lib/main.js (/var/task/netlify/functions/demo.js:76020:9)
at __require (/var/task/netlify/functions/demo.js:22:50)
at node_modules/vm2/index.js (/var/task/netlify/functions/demo.js:76048:23)
at __require (/var/task/netlify/functions/demo.js:22:50)
at node_modules/degenerator/dist/src/index.js (/var/task/netlify/functions/demo.js:76060:17)
at __require (/var/task/netlify/functions/demo.js:22:50)
Connection details
Netlify internal ID: 01H3KZK1WH991F7DFE6YY747NX
I don’t have file called bridge.js, just demo.js:
import { v2 as cloudinary } from 'cloudinary';
// Configure Cloudinary with your credentials
cloudinary.config({
cloud_name: '*****',
api_key: '*****',
api_secret: '*****'
});
exports.handler = async (event, context) => {
try {
// Create a text file with the word "HELLO"
const fileContent = 'HELLO';
// Upload the text file to Cloudinary
const result = await cloudinary.uploader.upload(fileContent, {
resource_type: 'raw',
folder: 'your_folder_name' // Optional: Specify the folder where you want to save the file
});
// The result object will contain information about the uploaded file
console.log(result);
return {
statusCode: 200,
body: JSON.stringify(result)
};
} catch (error) {
console.error('Error uploading file:', error);
return {
statusCode: 500,
body: JSON.stringify({ message: 'Error uploading file' })
};
}
};
It still errors even if I remove the actual upload and just have the config part.