Hello! I’m using the NextjsSite construct to deplo...
# help
d
Hello! I’m using the NextjsSite construct to deploy a stack. When I
yarn deploy
, the 3 NextJS lambdas are all using Node 12.x. How can I specify a NodeJS version for these NextjsSite construct lambdas?
I’ve seen that this underlying CDK construct has a runtime option, but I don’t see that I can specify that for the NextjsSite construct.
t
haha we're fixing this right now cc @Frank
d
Great to hear! Is there a workaround in the meantime?
We’ve got some optional chaining in our site’s codebase, and so we’re unable to deploy at the moment.
t
unfortunately no, the fix we're doing is bumping up to node16 does that work for you? or is there a reason you need to control it specifically
d
That would indeed fix it.
t
we can get this out soon
d
Any idea about timeline?
t
I'll let frank answer that but we should be able to get it out today
d
Awesome, thanks!
j
I've been having this same issue and wanted to add that after bumping the version to node 16, I started seeing the following. Not sure if you guys have run into it @Frank @thdxr
Copy code
{
  "errorType": "Error",
  "errorMessage": "Cannot find package 'aws-sdk' imported from /var/task/s3-bucket.js\nDid you mean to import aws-sdk/clients/s3.js?",
  "code": "ERR_MODULE_NOT_FOUND",
  "stack": [
    "Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'aws-sdk' imported from /var/task/s3-bucket.js",
    "Did you mean to import aws-sdk/clients/s3.js?",
    "    at new NodeError (node:internal/errors:371:5)",
    "    at packageResolve (node:internal/modules/esm/resolve:930:9)",
    "    at moduleResolve (node:internal/modules/esm/resolve:976:18)",
    "    at defaultResolve (node:internal/modules/esm/resolve:1078:11)",
    "    at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)",
    "    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)",
    "    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:79:40)",
    "    at link (node:internal/modules/esm/module_job:78:36)"
  ]
}
t
yeah this will be part of the fix
j
Awesome. Thanks!
d
maybe this is the fix, but any reason not to have it respect the defaults?
f
Yeah for the 3 user managed lambdas, we should respect the defaults. The SST managed ones, those will be updated to 16.
@Derek Kershner I couldn’t find the thread u posted about placing the Next.js app at the root. I gave it a try, and yes, it worked.
d
I deleted it, as I took another route, but that is interesting…
f
Updated the lambda runtime to Node 16 in
1.2.10
. And you can override it like this:
Copy code
new Function(stack, "Function", {
  path: "path/to/site",
  runtime: "nodejs16.x", // nodejs12.x or nodejs14.x
})
j
All working now. Thanks for the fix! @Frank @thdxr