```{ "errorType": "Error", "errorMessage":...
# help
a
Copy code
{
  "errorType": "Error",
  "errorMessage": "Cannot find module '/var/task/puppeteer/lib/Browser'\nRequire stack:\n- /var/task/credentialsApi.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
  "code": "MODULE_NOT_FOUND",
  "requireStack": [
    "/var/task/credentialsApi.js",
    "/var/runtime/UserFunction.js",
    "/var/runtime/index.js"
  ],
  "stack": [
    "Error: Cannot find module '/var/task/puppeteer/lib/Browser'",
    "Require stack:",
    "- /var/task/credentialsApi.js",
    "- /var/runtime/UserFunction.js",
    "- /var/runtime/index.js",
    "    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)",
    "    at Function.Module._load (internal/modules/cjs/loader.js:667:27)",
    "    at Module.require (internal/modules/cjs/loader.js:887:19)",
    "    at require (internal/modules/cjs/helpers.js:74:18)",
    "    at Function.get puppeteer [as puppeteer] (/node_modules/chrome-aws-lambda/source/index.ts:213:7)",
    "    at Runtime.createCredentials [as handler] (/src/credentials/credentialsApi.ts:75:34)",
    "    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
  ]
}
m
Can you check from the console whether the layer is attached or not? If yes, download the layer to see if node modules are installed (packed inside) or not.
a
let me check
looks like no layers
hmmm…..
m
lets attach it manually. just to make sure everything else works.
are you using sst function or cdk ?
a
sst
I added layer manually
Copy code
{
  "errorType": "Error",
  "errorMessage": "Cannot find module '/var/task/puppeteer/lib/Browser'\nRequire stack:\n- /var/task/credentialsApi.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
  "code": "MODULE_NOT_FOUND",
  "requireStack": [
    "/var/task/credentialsApi.js",
    "/var/runtime/UserFunction.js",
    "/var/runtime/index.js"
  ],
  "stack": [
    "Error: Cannot find module '/var/task/puppeteer/lib/Browser'",
    "Require stack:",
    "- /var/task/credentialsApi.js",
    "- /var/runtime/UserFunction.js",
    "- /var/runtime/index.js",
    "    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)",
    "    at Function.Module._load (internal/modules/cjs/loader.js:667:27)",
    "    at Module.require (internal/modules/cjs/loader.js:887:19)",
    "    at require (internal/modules/cjs/helpers.js:74:18)",
    "    at Function.get puppeteer [as puppeteer] (/node_modules/chrome-aws-lambda/source/index.ts:213:7)",
    "    at Runtime.createCredentials [as handler] (/src/credentials/credentialsApi.ts:75:34)",
    "    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
  ]
}
looks like the same shit
m
you are not using lambda aliasing right ? if so can you switch it to point to latest. its in the config section in console. Downloads the layer to see if there is node modules inside it. i believe it should have nodejs folder and modules inside it.
a
sorry, what should I change?
m
If this alias and version section is blank, then we are good with configs. (just download the layer and see if node modules exist inside it)
a
aliases empty
how can I download layer?
m
from here you should be able to find them
a
I can see puppeteer-core in archive, but no puppeteer
hmmm
m
is it there in package.json?
a
looks like yes, but zip file I used to create layer didn’t have this I think
I mean in the main project package json i have puppeter
m
probably need to show external modules in function I guess. https://docs.serverless-stack.com/constructs/Function#externalmodules
a
good point, I’ll try
m
Hey @Artem Kalantai, did it work?
a
no
nothing help, I can’t understand what I’m doing worng
did someone use the tutorial?
m
Give me 5 mins, I am trying on my system. and please share tutorial link.
m
This uses,
fromLayerVersionArn
, you are uploading layer assets, right? This is the one I am trying... https://docs.serverless-stack.com/working-locally#using-lambda-layers
a
layer assets? not sure
i just did what said in tutorial
m
did you use the same ARN value ?
a
i tried name from tutorial, when it wasn't work, i tried create my own layer and set arn from it, both didn't work
m
ok.. try this. you have already a zip of your layer code right. extract it. inside nodejs folder install all the node modules that you require then zip the nodejs folder again... (after extraction zip should result in nodejs folder with contents) then upload this newly created zip to you layer manually. first. then go to function and change/update the layer version to latest one. your api should work now. go back to your sst code now replace the layer version and arn with the one that you have (latest) and you should be good.
also, after that, try using this method to upload a layer. (I have also external modules in function def)
a
good will try and let you know
f
Hi @Artem Kalantai if you are still having the issue, can you share your repo? Might be easier that way.
j
Here’s the source for that tutorial btw, https://github.com/serverless-stack/examples/tree/main/layer-chrome-aws-lambda. I wrote it recently so we should be able to figure it out.
a
I'm not at laptop right now, in next 2 hours i'll try
it is so amazing that you are helping
@Mr.9715 I tried repack, but then I have error when trying create new version of layer, I’ll try @Jay tutorial, lets see how it work
Copy code
Failed to create layer version: Unzipped size must be smaller than 262144000 bytes
ok, after all i started example, it was working, then copypast to my project and voila everything works, not sure what i did wrong before, but thanks all of you for help and support
j
Great! Happy to help!