You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an error when trying to access my lambda function after it has been optimized.
I have tried to remove serverless-plugin-optimize and there is no problem (exept the package size which is 12Mb instead of 340Kb).
Here is the error I have when running sls invoke local --function myfunction):
{ Error: Cannot find module './dialects/mysql/index.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:613:15) at Function.Module._load (internal/modules/cjs/loader.js:539:25) at Module.require (internal/modules/cjs/loader.js:667:17) at require (internal/modules/cjs/helpers.js:20:18) ...
I'm using knex and it looks like this is the origin of the error.
After the code has been optimized I can see the following in handler.js
This code is normally part of node_module/knex/knex.js file.
${resolvedClientName} is filled at the execution with my database engine name. i.e. mysql.
But the local path ./dialects/${resolvedClientName}/index.js doesn't exists anymore since it has been optimized and there is no node_module/knex/{any_knex_tree_folder}
Is there a way to include it in optimized package ?
The text was updated successfully, but these errors were encountered:
A dirty solution is to fork the project, then to hardcode the ${resolvedClientName} var with your db client and to rebuild it as a local npm package.
I finally did without knex since that was not a reliable solution for a professional project due to this issue when combined with serverless-plugin-optimize.
Hello,
I have an error when trying to access my lambda function after it has been optimized.
I have tried to remove serverless-plugin-optimize and there is no problem (exept the package size which is 12Mb instead of 340Kb).
Here is the error I have when running sls invoke local --function myfunction):
{ Error: Cannot find module './dialects/mysql/index.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:613:15) at Function.Module._load (internal/modules/cjs/loader.js:539:25) at Module.require (internal/modules/cjs/loader.js:667:17) at require (internal/modules/cjs/helpers.js:20:18) ...
I'm using knex and it looks like this is the origin of the error.
After the code has been optimized I can see the following in handler.js
Dialect=require(
./dialects/${resolvedClientName}/index.js
)}This code is normally part of node_module/knex/knex.js file.
${resolvedClientName} is filled at the execution with my database engine name. i.e. mysql.
But the local path ./dialects/${resolvedClientName}/index.js doesn't exists anymore since it has been optimized and there is no node_module/knex/{any_knex_tree_folder}
Is there a way to include it in optimized package ?
The text was updated successfully, but these errors were encountered: