soubhagya
soubhagya

Reputation: 806

next.js deployment failed on amplify

    Starting SSR Build...
    2021-08-28T10:20:02.691Z [ERROR]: Error: Command failed with exit code 1: node_modules/.bin/next build
    warn  - No ESLint configuration detected. Run next lint to begin setup
    Browserslist: caniuse-lite is outdated. Please run:
    npx browserslist@latest --update-db
    Why you should do it regularly:
    https://github.com/browserslist/browserslist#browsers-data-updating
    Failed to compile.
    ModuleNotFoundError: Module not found: Error: Can't resolve 'mongodb' in '/codebuild/output/src826940630/src/frontend/node_modules/typeorm/platform'
    > Build error occurred
    Error: > Build failed because of webpack errors
    at /codebuild/output/src826940630/src/frontend/node_modules/next/dist/build/index.js:15:924
    at async Span.traceAsyncFn (/codebuild/output/src826940630/src/frontend/node_modules/next/dist/telemetry/trace/trace.js:6:584)
    info  - Loaded env from /codebuild/output/src826940630/src/frontend/.env.production
    info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
    info  - Checking validity of types...
    info  - Creating an optimized production build...
    at makeError (/root/.//node_modules/execa/lib/error.js:60:11)
    at handlePromise (/root/.//node_modules/execa/index.js:118:26)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Builder.build (/root/.//node_modules/@sls-next/lambda-at-edge/dist/build.js:348: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  - Loaded env from /codebuild/output/src826940630/src/frontend/.env.production\n' +
    'info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5\n' +
    'info  - Checking validity of types...\n' +
    'info  - Creating an optimized production build...',
    stderr: 'warn  - No ESLint configuration detected. Run next lint to begin setup\n' +
    'Browserslist: caniuse-lite is outdated. Please run:\n' +
    'npx browserslist@latest --update-db\n' +
    '\n' +
    'Why you should do it regularly:\n' +
    'https://github.com/browserslist/browserslist#browsers-data-updating\n' +
    'Failed to compile.\n' +
    '\n' +

I am trying to deploy my Next.js application to AWS amplify but it is failing like this some unknown mongodb error showing which I am not using anywhere in my application and it is only frontend.

Any idea how to fix this?

Upvotes: 1

Views: 2326

Answers (1)

Faesal
Faesal

Reputation: 823

I had this issue before: It was because of next version i changed it from the building settings in build image settings and set next version to 10 & it worked.

You should select your next version & follow these steps

Upvotes: 0

Related Questions