However when I “require” the package in my serverless function file, the package is not found: “‘crypto-js’ should be listed in the project’s dependencies.” (seams to find the file in the prompt? weird its not then found)
So of coarse when I run the code, the file logs it confirms not finding the package:
Hi, @JBrake Thank you for sharing your question. Let’s see if we can get the conversation going for you — hey @Teun@louischausse@Mike_Eastwood, can you lend a hand here?
Yes I’m getting that feeling too @Mike_Eastwood . In my google search I found a work aound but it no longer works as it folder is now alot more locked down. However here (bottom) it mentions webpacks, but I need an existing package from npm.
Any movement on this? Would love to know how to require external packages into a serverless function. None of the examples around work, all too old I suspect. Very frustrating
Best I’ve managed to to is put my required packages in to a separate project to render and take the dist output, find the place I need to add my code (marked by code in the code to be rendered) and then upload that as a serverless function… apart from the messness of this the (mostly minimised) code is not shared across multiple files and is often over the 170kb recommeded limit for serverless funcitons.
Yes, we have a src folder in our functions.functions folder and use node to bundle these up into the functions.functions folder which is then deployed to the server. Its pretty tidy. There really should be clearer documention about how to do this in the dev docs, or at least a link to some docs on how to set it up.
It is not very often we need to do this but have had to for things like stripe payment end points and encrytion.