Error using dependencies in functions
Hello there,
I'm trying to use a NodeJS14 Scaleway Functions to add features to a Scaleway Object Storage bucket. But, I can't find the way to use needed dependencies in my function...
When I initiate my two dependencies in the code, like this :
const AWS = require('aws-sdk');
const Sharp = require('sharp');
After installed both dependencies with npm install aws-sdk sharp, and getting the package.json's dependencies part correctly filled.
I got this response (after deployment) when I try to fetch the function over http :
An error occured during handler execution: Function Handler does not exist, check that you provided the right HANDLER parameter (path to your module with exported function to use)
However, without both import lines, the function is correctly working !
Could you help me please ?
Here my first test function :
const AWS = require('aws-sdk');
const Sharp = require('sharp');
module.exports.handle = (event, context, callback) => {
const photoId = event.queryStringParameters.id;
const size = event.queryStringParameters.size;
const result = {
message: 'Hello from Serverless Framework and Scaleway Functions :D',
photoId: photoId,
size: size
};
const response = {
statusCode: 200,
body: JSON.stringify(result),
};
return response;
};
And the corresponding serverless.yml :
service:
name: MyFunctions
configValidationMode: off
provider:
name: scaleway
runtime: node14
scwToken: '***'
scwOrganization: '***'
plugins:
- serverless-scaleway-functions
package:
exclude:
- .gitignore
- .git/**
- node_modules/**
functions:
first:
handler: handler.handle
env:
ACCESS_KEY: '***'
SECRET_KEY: '***'
BUCKET: '***'
Hello, did you try by removing the node_modules/** from your package.exclude list ?
I added it because without I got an error at deployment ( Serverless: Uploading source code... ) :
Error [ERR_FR_MAX_BODY_LENGTH_EXCEEDED]: Request body larger than maxBodyLength limit
Did you get this to work ?