sladg / nextjs-lambda

Lambda deployments for Nextjs12 & Nextjs13 (standalone). Easy CLI commands to get your standalone Next output to run in AWS Lambda (not @Edge)! Uses CDK in behind and produces code zips importable to Terraform, Serverless, Azure, etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Specified target is invalid. Provided: "standalone" should be one of server, serverless, experimental-serverless-trace

sennett opened this issue · comments

Thanks for this project. I'm having trouble running next build with target: 'standalone'. next.config.js is:

module.exports = {
  async redirects() {
    return [
      {
        source: '/town/:slug',
        destination: '/towns/:slug',
        permanent: true,
      },
    ]
  },
  output: 'standalone',
  target: 'standalone',
  compress: false,
}

When I run next built I get the following output:

Error: Specified target is invalid. Provided: "standalone" should be one of server, serverless, experimental-serverless-trace

Running npx --package @sladg/nextjs-lambda next-utils pack without this results in Process failed with error: Error: Folder: /Users/<project root>/.next/standalone does not exist!

From the next docs it seems we can have output: 'standalone',? But this doesn't seem to work either, or where am I going wrong? Thanks.

commented

Hey! just remove target it's not used, we just need to have output configured.

commented

I will fix documentation in a minute, sorry for confusion.

commented

Fixed in v3.20.4

Thanks! In addition, for me Next 12 didn't output a .next/standalone directory, and so the next step npx --package @sladg/nextjs-lambda next-utils pack failed. I have just updated to Next 13 and it is outputting the .next/standalone as expected. The docs mention Next 12 - I made a PR here specifying Next 13: #53.

commented

Next13 works fine for you however 12 did not output the directory? 🤔 that's sus

It was Next 12.1 - maybe there was something messed up in my yarn.lock.