CI Nextjs deployment with next.js runtime

This forum won’t let me post more then 1 media link so a more detailed description of the issue can be found here.


Deploying monorepo application via Netlify CLI results in “Not Found error” due to not picking up the @netlify/plugin-nextjs plugin for nextjs runtime but works correctly via UI production deployments.

Required info:

Repo: pr-with-deployment-issue
Site with error deployment:
Deployment settings:
CleanShot 2023-01-09 at 14.07.18

When deploying via CLI, you need to run: netlify deploy --build as the command. The --build flag is important.

Thanks @hrishikesh that did the trick!

@hrishikesh although that worked as intended locally, in a CI environment I receive the following error message. Oddly, without the --build flag this error is not reported under the exact same environment conditions?

GH Action run: fix: fixes deployment preview gh workflow · webb-tools/webb-dapp@be50d2b · GitHub
Workflow file: webb-dapp/landing-page-dapp-dev.yml at db/fix-webbsite-deploy · webb-tools/webb-dapp · GitHub

  Error message
  Command failed with ENOENT: yarn build:webbsite
  spawn bash ENOENT
  Error location
  In Build command from Netlify app:
  yarn build:webbsite

Hi @dutterbutter :wave:t6: I’m not sure what’s going on there. debugging code is outside the realm of support but I will leave this thread open for others who can help.

The solution to my issue was to ditch the netlify/actions/cli@master action and make use of the netlify cli within the job itself. Most importantly specifying the usage of bash shell. Example:

      # necessary for our monorepo structure 
      - name: Copy deployment config to root
        run: cp apps/webbsite/netlify.toml netlify.toml

      - name: Install dependencies
        run: yarn install

      - name: Install netlify-cli
        run: yarn add -D -W netlify-cli

      - name: Build project
        run: yarn build:webbsite

      - name: Deploy site
        shell: bash
        run : |
          npx netlify deploy --build context=deploy-preview --site $NETLIFY_WEBBSITE_ID --auth $NETLIFY_AUTH_TOKEN --dir=./dist/apps/webbsite/.next

Hope that helps someone in the future!