anyone got lucky deploying a nextjs 12 using the N...
# help
t
anyone got lucky deploying a nextjs 12 using the NextjsSite stack? I get this problem:
Error: Command failed with exit code 1: ./node_modules/.bin/next build
Failed to compile.
./next.config.js:1:27
Type error: Rest parameter 'args' implicitly has an 'any[]' type.
> 1 | module.exports = function(...args) {
|                           ^
2 |   let original = require('./next.config.original.1655555811863.js');
3 |   const finalConfig = {};
4 |   const target = { target: 'serverless' };
info  - Using webpack 5. Reason: Enabled by default <https://nextjs.org/docs/messages/webpack5>
info  - Checking validity of types...
at makeError (/Users/user/serveless-stack/node_modules/execa/lib/error.js:60:11)
at handlePromise (/Users/user/serveless-stack/node_modules/execa/index.js:118:26)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Builder.build (/Users/user/serveless-stack/node_modules/@sls-next/lambda-at-edge/dist/build.js:377:13) {
shortMessage: 'Command failed with exit code 1: ./node_modules/.bin/next build',
command: './node_modules/.bin/next build',
escapedCommand: '"./node_modules/.bin/next" build',
exitCode: 1,
signal: undefined,
signalDescription: undefined,
stdout: 'info  - Using webpack 5. Reason: Enabled by default <https://nextjs.org/docs/messages/webpack5>\n' +
according to https://github.com/aws-amplify/amplify-hosting/issues/2427 the { target: ‘serverless’ }; is no longer supported by it gets inserted automatically by the sst stack
d
We have several NextJs apps, all using next 12, all deploy fine. The target field is deprecated, but is still supported. It does look like your
next.config.js
file is the culprit, though, what do you have in there?
It almost looks like the types are getting checked while the temp next.config.js file is in place…
Maybe just turn type-checking off in sst.json
t
Thanks for your answer, my next.config.json looks like this
Copy code
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-var-requires
const withBundleAnalyzer = require("@next/bundle-analyzer")({
  enabled: process.env["ANALYZE"] === "true",
});

// eslint-disable-next-line @typescript-eslint/no-var-requires
const withTM = require("next-transpile-modules")([
  "@fullcalendar/common",
  "@fullcalendar/daygrid",
  "@fullcalendar/interaction",
  "@fullcalendar/list",
  "@fullcalendar/react",
  "@fullcalendar/timegrid",
  "@fullcalendar/timeline",
]);

/**
 * @type {import('next').NextConfig}
 **/
module.exports = withTM(
  withBundleAnalyzer({
    reactStrictMode: true,
    images: {
      domains: ["<http://assets.s3.amazonaws.com|assets.s3.amazonaws.com>"],
    },
  }),
);
you mean turning off the type checking in the tsconfig.json right?
Copy code
{
  "compilerOptions": {
    ...
    "checkJs": false
    ...
  }
}
d
actually, I may be mistaken and SST doesnt type-check automatically anymore…
but yes, explicitly ignoring that file with TSConfig should also work.
t
Thanks Derek disabling type check works or just excluding the next.config.js file
"exclude": ["node_modules", "./next", "next.config.js"]