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.
MIT License
169 stars 19 forks source link

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

Closed sennett closed 1 year ago

sennett commented 1 year ago

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.

sladg commented 1 year ago

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

sladg commented 1 year ago

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

sladg commented 1 year ago

Fixed in v3.20.4

sennett commented 1 year ago

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: https://github.com/sladg/nextjs-lambda/pull/53.

sladg commented 1 year ago

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

sennett commented 1 year ago

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