I’m having a new issue since the most recent SST r...
# help
s
I’m having a new issue since the most recent SST release. I think it has to do with code being executed from
.sst/artifacts
now, maybe.
here’s the error:
Copy code
Something went wrong installing the "sharp" module

Cannot find module '../build/Release/sharp-darwin-x64.node'
Require stack:
- /Volumes/SuperData/Sites/reelcrafter/v2-microservices/.sst/artifacts/9ed24b68/src/lambda/rest/functions/update-media.js
- /Volumes/SuperData/Sites/reelcrafter/v2-microservices/node_modules/@serverless-stack/aws-lambda-ric/lib/utils/UserFunction.js
- /Volumes/SuperData/Sites/reelcrafter/v2-microservices/node_modules/@serverless-stack/aws-lambda-ric/lib/index.js
- /Volumes/SuperData/Sites/reelcrafter/v2-microservices/node_modules/@serverless-stack/aws-lambda-ric/bin/index.js
but the
.node
file it’s looking for totally exists in
node_modules/sharp
. this was working ok before
@Frank any ideas on this? this has become a blocker for us
well.. I mean, I could just downgrade to the previous version of SST
oh no. downgrading to 0.54.4 didn’t fix this.. dang
f
Hey @Sam Hulick, are you getting this on
sst start
or
sst deploy
?
s
sst start
. I’m trying something else.. I ran
node_modules/sharp/build/Release/sharp-darwin-x64.node
and it gave me an exec error, which tells me that, despite that filename, it’s actually not compiled correctly for my Mac
I’m gonna reinstall sharp and see if that fixes it
nope. sharp is working fine. I can’t execute that file, but I guess that’s not how it works 😄 I wrote a small JS script to convert a PNG and it worked ok
so SST truly cannot find the sharp module
oh, maybe this has to do with the SST change where it builds functions on demand
Copy code
[2021-12-28T13:26:22.309] [DEBUG] client - First build...
[2021-12-28T13:26:22.849] [DEBUG] client - First build finished
[2021-12-28T13:26:22.850] [DEBUG] client - Spawning {
  command: 'npx',
  args: [
    'aws-lambda-ric',
    '/Volumes/SuperData/Sites/reelcrafter/v2-microservices/.sst/artifacts/9ed24b68/src/lambda/rest/functions/update-media.main'
  ],
  env: { AWS_LAMBDA_NODEJS_USE_ALTERNATIVE_CLIENT_1: 'true' }
}
[2021-12-28T13:26:23.849] [INFO] client -
Something went wrong installing the "sharp" module
f
I see.. so you are doing an
import
sharp
in ur function code?
s
yeah
f
lemme cc @thdxr in case he’s seen this before
And is
sharp
inside the
node_modules
?
s
it sure is
Copy code
node_modules/sharp/build/Release/
└── sharp-darwin-x64.node
f
it seems it’s looking at the wrong path
Copy code
Cannot find module '../build/Release/sharp-darwin-x64.node'
s
yeah, that must be what’s happening. but unfortunately I don’t think I have any control over that. I can’t tell what part of the SST process is looking for that module
f
can you try listing
sharp
under
bundle.externalModules
?
s
sure, one sec
hey, that worked!! thanks a bunch 🙂 previously I was only using sharp as an external in production, since I have it in a Lambda layer. I didn’t need to do that locally before
f
ah nice. yeah, by setting it in
externalModules
we are bypassing esbuild and the version in
node_modules
will be used.
s
makes sense. I didn’t think to set it as external. thanks again! 😎
t
Hey sorry thought I responded to this in the morning. We made a change to more closely mirror local and prod bundles so there were fewer discrepencies
So now things get bundled locally the same way they would in prod, so that's why you had to remove the IS_LOCAL flag
s
ahhh! that’s a great change. the more local & prod are similar, the less likely it is to run into the typical issue where something works great..until you launch it into production 😅
b