When trying to import npm modules into `aws.lambda...
# getting-started
e
When trying to import npm modules into
aws.lambda.callbackFunction
, I get an error. This has happened so far with
yup
,
zod
,
joi
and
validator.js
. Currently I am working on just the
validator.js
issue, which I will paste below:
Copy code
error: Error: Error serializing '() => { // const { object, string }  ...': main.js(1505,40)

    '() => { // const { object, string }  ...': main.js(1505,40): captured
      variable 'util_helpers_1' which indirectly referenced
        function 'get': main.js(2343,46): which captured
          variable 'm' which indirectly referenced
            '(countryCode) => { if (countryCode = ...': main.js(2240,33): which captured
              'isISO31661Alpha3_1', a function defined at
                function 'isISO31661Alpha3': main.js(1178,25): which captured
                  variable 'validISO31661Alpha3CountriesCodes' which indirectly referenced
                    function 'has': which could not be serialized because
                      it was a native code function.

    Function code:
      function has() { [native code] }
Any guidance will help. I have been running into this issue for the last few days and cannot find a solution
This only happens with one of the validators I am using,
isISO31661Alpha3
with the
Set.has
function
^ I figured it out this case by just not importing the
es
module that was exported
Fixed the yup issue by switching to having only one package.json issue in my monorepo (using
nx
and
@wanews/nx-pulumi
) and symlinking
node_modules
and
package.json
in every
pulumi
app and putting all the dependencies in the root
package.json