I started getting this error after I updated the `...
# help
s
I started getting this error after I updated the
sst
today to
1.2.9
Copy code
Could not resolve "mock-aws-s3"

    node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:43:28:
      43 │     const AWSMock = require('mock-aws-s3');
         ╵                             ~~~~~~~~~~~~~

  You can mark the path "mock-aws-s3" as external to exclude it from the bundle, which will remove
  this error. You can also surround this "require" call with a try/catch block to handle this
  failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "pg-native"

    node_modules/pg/lib/native/client.js:4:21:
      4 │ var Native = require('pg-native')
        ╵                      ~~~~~~~~~~~

  You can mark the path "pg-native" as external to exclude it from the bundle, which will remove
  this error. You can also surround this "require" call with a try/catch block to handle this
  failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "nock"

    node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:112:23:
      112 │   const nock = require('nock');
          ╵                        ~~~~~~

  You can mark the path "nock" as external to exclude it from the bundle, which will remove this
  error. You can also surround this "require" call with a try/catch block to handle this failure at
  run-time instead of bundle-time.
t
when do you get these errors?
s
Today
t
haha no I meant do you get this during sst start? sst deploy?
s
When I hit an API endpoint which was working previously.
t
during sst start?
what version were you on before?
s
It was ^1.0.2 but now 1.2.9.
t
have you tried clearing node modules?
I'm not able to tell too much with this error
k
pg-native sounds like something you should exclude for esbuild
s
I tried reinstalling by removing the node modules and even tried by removing the stage completely, it is still giving the same error.
k
in an old serverless project I remember errors unless I used
Copy code
esbuild:
    bundle: true
    packager: npm
    exclude: ['pg-native'] // <<--
s
@Klaus In which file should I add this?
t
the thing is if this is during sst start and was working before something seems off
k
Copy code
new Function(stack, "MyLambda", {
  bundle: {
    externalModules: ["pg-native"],
try that above
but yeah, also not sire why it might have worked before
s
@Klaus Tried that, it searches for
package.json
in that lamda directory.
Which again gives another error.
k
@thdxr shouldn't the normal package.json be used by following the nodeJS config instructions for bundling
@Swapnil Bandiwadekar are you using a postgres Database module like
pg
? Seeing your package.json + the way you define the data base related function might be useful
s
@Klaus Its actually another package that uses it.
k
I think in order to replicate the error, sharing your setup would be great for our friendly guys at SST😉 The error alone won't be enough to figure out why it happens