Cannot deploy, next-auth is throwing error

Site name: https://enchanting-fudge-99b59b.netlify.app
custom domain: wyzr.in

I’m trying to deploy our site in preview mode, but I get the following error during the build time:

7:01:34 PM: build-image version: 1ca34a93198b041e44214013884c57d146a23fed (focal)
7:01:34 PM: build-image tag: v4.16.4
7:01:34 PM: buildbot version: 5d70ebdb976733297fb4c90b41002389a248e2df
7:01:34 PM: Fetching cached dependencies
7:01:34 PM: Starting to download cache of 499.6MB
7:01:38 PM: Finished downloading cache in 3.991s
7:01:38 PM: Starting to extract cache
7:01:44 PM: Finished extracting cache in 6.194s
7:01:44 PM: Finished fetching cache in 10.267s
7:01:44 PM: Starting to prepare the repo for build
7:01:44 PM: Preparing Git Reference pull/21/head
7:01:46 PM: Parsing package.json dependencies
7:01:47 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'next-main/out' versus '' in the Netlify UI
7:01:47 PM: Starting build script
7:01:47 PM: Installing dependencies
7:01:47 PM: Python version set to 2.7
7:01:47 PM: Started restoring cached Node.js version
7:01:48 PM: Finished restoring cached Node.js version
7:01:48 PM: v16.19.0 is already installed.
7:01:48 PM: Now using node v16.19.0 (npm v8.19.3)
7:01:48 PM: Enabling Node.js Corepack
7:01:48 PM: Started restoring cached build plugins
7:01:48 PM: Finished restoring cached build plugins
7:01:48 PM: Attempting Ruby version 2.7.2, read from environment
7:01:49 PM: Using Ruby version 2.7.2
7:01:49 PM: Using PHP version 8.0
7:01:49 PM: Started restoring cached corepack dependencies
7:01:49 PM: mv: cannot move '/opt/build/cache/.node/corepack' to '/opt/buildhome/.node/corepack': No such file or directory
7:01:49 PM: Finished restoring cached corepack dependencies
7:01:49 PM: Started restoring cached yarn cache
7:01:51 PM: Finished restoring cached yarn cache
7:01:51 PM: Installing Yarn version 1.22.10
7:01:51 PM: Preparing yarn@1.22.10 for immediate activation...
7:01:51 PM: No yarn workspaces detected
7:01:51 PM: Started restoring cached node modules
7:01:51 PM: Finished restoring cached node modules
7:01:51 PM: Installing npm packages using Yarn version 1.22.10
7:01:52 PM: yarn install v1.22.10
7:01:52 PM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
7:01:52 PM: [1/4] Resolving packages...
7:01:54 PM: [2/4] Fetching packages...
7:01:57 PM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
7:01:57 PM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-darwin-arm64@0.14.39: The platform "linux" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-darwin-arm64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-darwin-arm64@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:01:57 PM: info @netlify/esbuild-darwin-64@0.14.39: The platform "linux" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-darwin-64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-android-arm64@0.14.39: The platform "linux" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-android-arm64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-android-arm64@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:01:57 PM: info @netlify/esbuild-freebsd-64@0.14.39: The platform "linux" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-freebsd-64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-freebsd-arm64@0.14.39: The platform "linux" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-freebsd-arm64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-freebsd-arm64@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:01:57 PM: info @netlify/esbuild-linux-32@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-linux-32@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-linux-mips64le@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-linux-mips64le@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-linux-arm64@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-linux-arm64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-linux-arm@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-linux-arm@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-linux-ppc64le@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-linux-ppc64le@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-linux-s390x@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-linux-s390x@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-linux-riscv64@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-linux-riscv64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-windows-64@0.14.39: The platform "linux" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-windows-64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-netbsd-64@0.14.39: The platform "linux" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-netbsd-64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-openbsd-64@0.14.39: The platform "linux" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-openbsd-64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-windows-arm64@0.14.39: The platform "linux" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-windows-arm64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-windows-arm64@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:01:57 PM: info @netlify/esbuild-sunos-64@0.14.39: The platform "linux" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-sunos-64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-android-64@0.14.39: The platform "linux" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-android-64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-windows-32@0.14.39: The platform "linux" is incompatible with this module.
7:01:57 PM: info "@netlify/esbuild-windows-32@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @netlify/esbuild-windows-32@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:01:57 PM: info @next/swc-darwin-x64@11.1.2: The platform "linux" is incompatible with this module.
7:01:57 PM: info "@next/swc-darwin-x64@11.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @next/swc-win32-x64-msvc@11.1.2: The platform "linux" is incompatible with this module.
7:01:57 PM: info "@next/swc-win32-x64-msvc@11.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @next/swc-darwin-arm64@11.1.2: The platform "linux" is incompatible with this module.
7:01:57 PM: info "@next/swc-darwin-arm64@11.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
7:01:57 PM: info @next/swc-darwin-arm64@11.1.2: The CPU architecture "x64" is incompatible with this module.
7:01:57 PM: [3/4] Linking dependencies...
7:01:57 PM: warning " > @chakra-ui/icons@1.0.13" has unmet peer dependency "@chakra-ui/system@>=1.0.0".
7:01:57 PM: warning "@chakra-ui/icons > @chakra-ui/icon@1.1.9" has unmet peer dependency "@chakra-ui/system@>=1.0.0".
7:01:57 PM: warning "@chakra-ui/react > @chakra-ui/modal > react-remove-scroll@2.4.1" has incorrect peer dependency "react@^16.8.0 || ^17.0.0".
7:01:57 PM: warning "@chakra-ui/react > @chakra-ui/toast > @reach/alert@0.13.2" has incorrect peer dependency "react@^16.8.0 || 17.x".
7:01:57 PM: warning "@chakra-ui/react > @chakra-ui/toast > @reach/alert@0.13.2" has incorrect peer dependency "react-dom@^16.8.0 || 17.x".
7:01:57 PM: warning "@chakra-ui/react > @chakra-ui/modal > @chakra-ui/focus-lock > react-focus-lock@2.5.0" has incorrect peer dependency "react@^16.8.0 || ^17.0.0".
7:01:57 PM: warning "@chakra-ui/react > @chakra-ui/modal > react-remove-scroll > react-remove-scroll-bar@2.2.0" has incorrect peer dependency "react@^16.8.0 || ^17.0.0".
7:01:57 PM: warning "@chakra-ui/react > @chakra-ui/modal > react-remove-scroll > react-style-singleton@2.1.1" has incorrect peer dependency "react@^16.8.0 || ^17.0.0".
7:01:57 PM: warning "@chakra-ui/react > @chakra-ui/modal > react-remove-scroll > use-callback-ref@1.2.5" has incorrect peer dependency "react@^16.8.0 || ^17.0.0".
7:01:57 PM: warning "@chakra-ui/react > @chakra-ui/modal > react-remove-scroll > use-sidecar@1.0.5" has incorrect peer dependency "react@^16.8.0 || ^17.0.0".
7:01:57 PM: warning "@chakra-ui/react > @chakra-ui/toast > @reach/alert > @reach/utils@0.13.2" has incorrect peer dependency "react@^16.8.0 || 17.x".
7:01:57 PM: warning "@chakra-ui/react > @chakra-ui/toast > @reach/alert > @reach/utils@0.13.2" has incorrect peer dependency "react-dom@^16.8.0 || 17.x".
7:01:57 PM: warning "@chakra-ui/react > @chakra-ui/toast > @reach/alert > @reach/visually-hidden@0.13.2" has incorrect peer dependency "react@^16.8.0 || 17.x".
7:01:57 PM: warning "@chakra-ui/react > @chakra-ui/toast > @reach/alert > @reach/visually-hidden@0.13.2" has incorrect peer dependency "react-dom@^16.8.0 || 17.x".
7:01:57 PM: warning "@chakra-ui/react > @chakra-ui/modal > @chakra-ui/focus-lock > react-focus-lock > react-clientside-effect@1.2.5" has incorrect peer dependency "react@^15.3.0 || ^16.0.0 || ^17.0.0".
7:01:57 PM: warning "@emotion/styled > @emotion/babel-plugin@11.3.0" has unmet peer dependency "@babel/core@^7.0.0".
7:01:57 PM: warning "@emotion/styled > @emotion/babel-plugin > @babel/plugin-syntax-jsx@7.14.5" has unmet peer dependency "@babel/core@^7.0.0-0".
7:01:57 PM: warning " > @microsoft/applicationinsights-react-js@3.1.5" has incorrect peer dependency "react@^17.0.1".
7:01:57 PM: warning " > next@11.1.2" has incorrect peer dependency "react@^17.0.2".
7:01:57 PM: warning " > next@11.1.2" has incorrect peer dependency "react-dom@^17.0.2".
7:01:57 PM: warning "next > @next/react-dev-overlay@11.1.2" has incorrect peer dependency "react@^17.0.2".
7:01:57 PM: warning "next > @next/react-dev-overlay@11.1.2" has incorrect peer dependency "react-dom@^17.0.2".
7:01:57 PM: warning "next > use-subscription@1.5.1" has incorrect peer dependency "react@^16.8.0 || ^17.0.0".
7:01:57 PM: warning " > next-auth@4.19.1" has incorrect peer dependency "next@^12.2.5 || ^13".
7:01:57 PM: warning " > file-loader@6.2.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
7:01:59 PM: [4/4] Building fresh packages...
7:02:00 PM: success Saved lockfile.
7:02:00 PM: Done in 8.75s.
7:02:00 PM: npm packages installed using Yarn
7:02:00 PM: Started restoring cached go cache
7:02:00 PM: Finished restoring cached go cache
7:02:00 PM: Installing Go version 1.16.5 (requested 1.16.5)
7:02:04 PM: unset GOOS;
7:02:04 PM: unset GOARCH;
7:02:04 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64';
7:02:04 PM: export PATH="/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64/bin:${PATH}";
7:02:04 PM: go version >&2;
7:02:04 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.16.5.linux.amd64.env"
7:02:04 PM: go version go1.16.5 linux/amd64
7:02:05 PM: Detected 1 framework(s)
7:02:05 PM: "next" at version "11.1.2"
7:02:05 PM: Installing missing commands
7:02:05 PM: Verify run directory
7:02:05 PM: Section completed: initializing
7:02:06 PM: ​
7:02:06 PM:   Netlify Build                                                 
7:02:06 PM: ────────────────────────────────────────────────────────────────
7:02:06 PM: ​
7:02:06 PM: ❯ Version
7:02:06 PM:   @netlify/build 29.5.1
7:02:06 PM: ​
7:02:06 PM: ❯ Flags
7:02:06 PM:   baseRelDir: true
7:02:06 PM:   buildId: 63d9183456447e0008be73dc
7:02:06 PM:   deployId: 63d9183456447e0008be73de
7:02:06 PM: ​
7:02:06 PM: ❯ Current directory
7:02:06 PM:   /opt/build/repo/next-main
7:02:06 PM: ​
7:02:06 PM: ❯ Config file
7:02:06 PM:   /opt/build/repo/next-main/netlify.toml
7:02:06 PM: ​
7:02:06 PM: ❯ Context
7:02:06 PM:   deploy-preview
7:02:06 PM: ​
7:02:06 PM: ❯ Using Next.js Runtime - v4.30.3
7:02:08 PM: ​
7:02:08 PM:   1. @netlify/plugin-nextjs (onPreBuild event)                  
7:02:08 PM: ────────────────────────────────────────────────────────────────
7:02:08 PM: ​
7:02:08 PM: No Next.js cache to restore.
7:02:08 PM: Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed.
7:02:08 PM: ​
7:02:08 PM: (@netlify/plugin-nextjs onPreBuild completed in 18ms)
7:02:08 PM: ​
7:02:08 PM:   2. build.command from netlify.toml                            
7:02:08 PM: ────────────────────────────────────────────────────────────────
7:02:08 PM: ​
7:02:08 PM: $ yarn build
7:02:08 PM: yarn run v1.22.10
7:02:08 PM: $ next build
7:02:08 PM: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
7:02:08 PM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
7:02:08 PM: Browserslist: caniuse-lite is outdated. Please run:
7:02:08 PM: npx browserslist@latest --update-db
7:02:08 PM: Why you should do it regularly:
7:02:08 PM: https://github.com/browserslist/browserslist#browsers-data-updating
7:02:08 PM: info  - Checking validity of types...
7:02:15 PM: Failed to compile.
7:02:15 PM: 
7:02:15 PM: ./node_modules/next-auth/next/index.d.ts:18:61
7:02:15 PM: Type error: '>' expected.
7:02:15 PM:   16 | export declare function unstable_getServerSession<O extends GetServerSessionOptions, R = O["callbacks"] extends {
7:02:15 PM:   17 |     session: (...args: any[]) => infer U;
7:02:15 PM: > 18 | } ? U : Session>(...args: Parameters<typeof getServerSession<O, R>>): ReturnType<typeof getServerSession<O, R>>;
7:02:15 PM:      |                                                             ^
7:02:15 PM:   19 | declare global {
7:02:15 PM:   20 |     namespace NodeJS {
7:02:15 PM:   21 |         interface ProcessEnv {
7:02:16 PM: error Command failed with exit code 1. (https://ntl.fyi/exit-code-1)
7:02:16 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
7:02:16 PM: ​
7:02:16 PM:   "build.command" failed                                        
7:02:16 PM: ────────────────────────────────────────────────────────────────
7:02:16 PM: ​
7:02:16 PM:   Error message
7:02:16 PM:   Command failed with exit code 1: yarn build (https://ntl.fyi/exit-code-1)
7:02:16 PM: ​
7:02:16 PM:   Error location
7:02:16 PM:   In build.command from netlify.toml:
7:02:16 PM:   yarn build
7:02:16 PM: ​
7:02:16 PM:   Resolved config
7:02:16 PM:   build:
7:02:16 PM:     base: /opt/build/repo/next-main
7:02:16 PM:     command: yarn build
7:02:16 PM:     commandOrigin: config
7:02:16 PM:     environment:
7:02:16 PM:       - NETLIFY_GRAPH_TOKEN
7:02:16 PM:       - NEXT_PUBLIC_DOMAIN_URL
7:02:16 PM:       - NEXT_PUBLIC_MAIN_WEBSITE
7:02:16 PM:       - NEXT_PUBLIC_RAZORPAY_KEY
7:02:16 PM:       - ONEGRAPH_AUTHLIFY_TOKEN
7:02:16 PM:       - REVIEW_ID
7:02:16 PM:       - NEXT_PRIVATE_TARGET
7:02:16 PM:     publish: /opt/build/repo/next-main/out
7:02:16 PM:     publishOrigin: config
7:02:16 PM:   plugins:
7:02:16 PM:     - inputs: {}
7:02:16 PM:       origin: config
7:02:16 PM:       package: '@netlify/plugin-nextjs'
7:02:16 PM: Caching artifacts
7:02:16 PM: Started saving node modules
7:02:18 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
7:02:16 PM: Finished saving node modules
7:02:16 PM: Started saving build plugins
7:02:16 PM: Finished saving build plugins
7:02:16 PM: Started saving yarn cache
7:02:18 PM: Finished saving yarn cache
7:02:18 PM: Started saving pip cache
7:02:18 PM: Finished saving pip cache
7:02:18 PM: Started saving emacs cask dependencies
7:02:18 PM: Finished saving emacs cask dependencies
7:02:18 PM: Started saving maven dependencies
7:02:18 PM: Finished saving maven dependencies
7:02:18 PM: Started saving boot dependencies
7:02:18 PM: Finished saving boot dependencies
7:02:18 PM: Started saving rust rustup cache
7:02:18 PM: Finished saving rust rustup cache
7:02:18 PM: Started saving go dependencies
7:02:18 PM: Finished saving go dependencies
7:02:18 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
7:02:18 PM: Failing build: Failed to build site
7:02:18 PM: Finished processing build request in 44.105s

I’m using next-auth 4.18.8 for authentication with next13. Here is my package.json file:

{
  "name": "wyzr-main-website",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev -p 3003",
    "start": "next start",
    "lint": "eslint ./ --ignore-path .gitignore",
    "lint:fix": "npm run lint -- --fix",
    "build": "next build",
    "build:prod": "next build && next export && rm -rf node_modules"
  },
  "dependencies": {
    "@chakra-ui/icons": "^1.0.0",
    "@chakra-ui/react": "^1.4.2",
    "@emotion/react": "^11.0.0",
    "@emotion/styled": "^11.0.0",
    "@microsoft/applicationinsights-react-js": "^3.1.5",
    "@microsoft/applicationinsights-web": "^2.6.5",
    "@netlify/plugin-nextjs": "^4.29.3",
    "axios": "^0.21.1",
    "file-saver": "^2.0.5",
    "formik": "^2.2.9",
    "framer-motion": "^4.0.3",
    "history": "^5.0.1",
    "js-file-download": "^0.4.12",
    "next": "latest",
    "next-auth": "^4.18.8",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-icons": "^4.2.0",
    "react-responsive-carousel": "^3.2.22",
    "react-tweet-embed": "^1.3.1",
    "swiper": "^7.4.1"
  },
  "devDependencies": {
    "@types/file-saver": "^2.0.4",
    "@types/history": "^4.7.9",
    "@typescript-eslint/eslint-plugin": "^4.28.1",
    "@typescript-eslint/parser": "^4.28.1",
    "critters": "^0.0.10",
    "eslint": "^7.29.0",
    "eslint-config-next": "^11.0.1",
    "eslint-plugin-react": "^7.24.0",
    "file-loader": "^6.2.0",
    "typescript": "^4.3.4"
  }
}

The error seems to be coming from next-auth.

Hi there, glad you found us :wave:t6: ,

Here a similar solution that another user tried. Can you give this a try? Next-Auth - Error: This action with HTTP GET is not supported by NextAuth.js - #4 by franknoirot

Got this error upon updating all packages to their latest versions as mentioned in the above link.

7:42:30 AM: build-image version: ada486d80800a9a84b567366a5bfe2beab07892e (focal)
7:42:30 AM: buildbot version: ada486d80800a9a84b567366a5bfe2beab07892e
7:42:30 AM: Fetching cached dependencies
7:42:30 AM: Starting to download cache of 499.6MB
7:42:36 AM: Finished downloading cache in 5.475s
7:42:36 AM: Starting to extract cache
7:42:38 AM: Finished extracting cache in 2.358s
7:42:38 AM: Finished fetching cache in 7.917s
7:42:38 AM: Starting to prepare the repo for build
7:42:39 AM: Preparing Git Reference pull/21/head
7:42:40 AM: Parsing package.json dependencies
7:42:41 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'next-main/out' versus '' in the Netlify UI
7:42:41 AM: Starting build script
7:42:41 AM: Installing dependencies
7:42:41 AM: Python version set to 2.7
7:42:42 AM: Started restoring cached Node.js version
7:42:42 AM: Finished restoring cached Node.js version
7:42:42 AM: v16.19.0 is already installed.
7:42:43 AM: Now using node v16.19.0 (npm v8.19.3)
7:42:43 AM: Enabling Node.js Corepack
7:42:43 AM: Started restoring cached build plugins
7:42:43 AM: Finished restoring cached build plugins
7:42:43 AM: Attempting Ruby version 2.7.2, read from environment
7:42:43 AM: Using Ruby version 2.7.2
7:42:44 AM: Using PHP version 8.0
7:42:44 AM: Started restoring cached corepack dependencies
7:42:44 AM: mv: cannot move '/opt/build/cache/.node/corepack' to '/opt/buildhome/.node/corepack': No such file or directory
7:42:44 AM: Finished restoring cached corepack dependencies
7:42:44 AM: Started restoring cached yarn cache
7:42:45 AM: Finished restoring cached yarn cache
7:42:45 AM: Installing Yarn version 1.22.10
7:42:45 AM: Preparing yarn@1.22.10 for immediate activation...
7:42:45 AM: No yarn workspaces detected
7:42:45 AM: Started restoring cached node modules
7:42:45 AM: Finished restoring cached node modules
7:42:46 AM: Installing npm packages using Yarn version 1.22.10
7:42:46 AM: yarn install v1.22.10
7:42:46 AM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
7:42:46 AM: [1/4] Resolving packages...
7:42:56 AM: [2/4] Fetching packages...
7:43:02 AM: info @netlify/esbuild-freebsd-64@0.14.39: The platform "linux" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-freebsd-64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-darwin-arm64@0.14.39: The platform "linux" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-darwin-arm64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-darwin-arm64@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:43:02 AM: info @netlify/esbuild-android-arm64@0.14.39: The platform "linux" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-android-arm64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-android-arm64@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:43:02 AM: info @netlify/esbuild-darwin-64@0.14.39: The platform "linux" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-darwin-64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-linux-32@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-linux-32@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-freebsd-arm64@0.14.39: The platform "linux" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-freebsd-arm64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-freebsd-arm64@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:43:02 AM: info @netlify/esbuild-linux-arm@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-linux-arm@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-linux-arm64@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-linux-arm64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-linux-mips64le@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-linux-mips64le@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-linux-riscv64@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-linux-riscv64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-linux-s390x@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-linux-s390x@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-sunos-64@0.14.39: The platform "linux" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-sunos-64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-netbsd-64@0.14.39: The platform "linux" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-netbsd-64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-openbsd-64@0.14.39: The platform "linux" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-openbsd-64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-windows-32@0.14.39: The platform "linux" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-windows-32@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-windows-32@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:43:02 AM: info @netlify/esbuild-linux-ppc64le@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-linux-ppc64le@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-windows-64@0.14.39: The platform "linux" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-windows-64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-windows-arm64@0.14.39: The platform "linux" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-windows-arm64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-windows-arm64@0.14.39: The CPU architecture "x64" is incompatible with this module.
7:43:02 AM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
7:43:02 AM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @netlify/esbuild-android-64@0.14.39: The platform "linux" is incompatible with this module.
7:43:02 AM: info "@netlify/esbuild-android-64@0.14.39" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @next/swc-darwin-x64@11.1.2: The platform "linux" is incompatible with this module.
7:43:02 AM: info "@next/swc-darwin-x64@11.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @next/swc-darwin-arm64@11.1.2: The platform "linux" is incompatible with this module.
7:43:02 AM: info "@next/swc-darwin-arm64@11.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: info @next/swc-darwin-arm64@11.1.2: The CPU architecture "x64" is incompatible with this module.
7:43:02 AM: info @next/swc-win32-x64-msvc@11.1.2: The platform "linux" is incompatible with this module.
7:43:02 AM: info "@next/swc-win32-x64-msvc@11.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
7:43:02 AM: [3/4] Linking dependencies...
7:43:02 AM: warning " > @chakra-ui/icons@2.0.17" has unmet peer dependency "@chakra-ui/system@>=2.0.0".
7:43:02 AM: warning "@chakra-ui/icons > @chakra-ui/icon@3.0.16" has unmet peer dependency "@chakra-ui/system@>=2.0.0".
7:43:02 AM: warning "@emotion/react > @emotion/babel-plugin@11.10.5" has unmet peer dependency "@babel/core@^7.0.0".
7:43:02 AM: warning "@emotion/react > @emotion/babel-plugin > @babel/plugin-syntax-jsx@7.18.6" has unmet peer dependency "@babel/core@^7.0.0-0".
7:43:02 AM: warning " > @microsoft/applicationinsights-react-js@3.4.0" has unmet peer dependency "tslib@*".
7:43:02 AM: warning "@microsoft/applicationinsights-react-js > @microsoft/applicationinsights-common@2.8.9" has unmet peer dependency "tslib@*".
7:43:02 AM: warning "@microsoft/applicationinsights-react-js > @microsoft/applicationinsights-core-js@2.8.9" has unmet peer dependency "tslib@*".
7:43:02 AM: warning " > @microsoft/applicationinsights-web@2.8.9" has unmet peer dependency "tslib@*".
7:43:02 AM: warning "@microsoft/applicationinsights-web > @microsoft/applicationinsights-dependencies-js@2.8.9" has unmet peer dependency "tslib@*".
7:43:02 AM: warning "@microsoft/applicationinsights-web > @microsoft/applicationinsights-analytics-js@2.8.9" has unmet peer dependency "tslib@*".
7:43:02 AM: warning "@microsoft/applicationinsights-web > @microsoft/applicationinsights-properties-js@2.8.9" has unmet peer dependency "tslib@*".
7:43:02 AM: warning "@microsoft/applicationinsights-web > @microsoft/applicationinsights-channel-js@2.8.9" has unmet peer dependency "tslib@*".
7:43:02 AM: warning " > next@11.1.2" has incorrect peer dependency "react@^17.0.2".
7:43:02 AM: warning " > next@11.1.2" has incorrect peer dependency "react-dom@^17.0.2".
7:43:02 AM: warning "next > @next/react-dev-overlay@11.1.2" has incorrect peer dependency "react@^17.0.2".
7:43:02 AM: warning "next > @next/react-dev-overlay@11.1.2" has incorrect peer dependency "react-dom@^17.0.2".
7:43:02 AM: warning "next > use-subscription@1.5.1" has incorrect peer dependency "react@^16.8.0 || ^17.0.0".
7:43:02 AM: warning "next > styled-jsx > @babel/plugin-syntax-jsx@7.14.5" has unmet peer dependency "@babel/core@^7.0.0-0".
7:43:02 AM: warning " > next-auth@4.19.2" has incorrect peer dependency "next@^12.2.5 || ^13".
7:43:02 AM: warning " > file-loader@6.2.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
7:43:06 AM: [4/4] Building fresh packages...
7:43:08 AM: success Saved lockfile.
7:43:08 AM: Done in 21.83s.
7:43:08 AM: npm packages installed using Yarn
7:43:08 AM: Started restoring cached go cache
7:43:08 AM: Finished restoring cached go cache
7:43:08 AM: Installing Go version 1.16.5 (requested 1.16.5)
7:43:12 AM: unset GOOS;
7:43:12 AM: unset GOARCH;
7:43:12 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64';
7:43:12 AM: export PATH="/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64/bin:${PATH}";
7:43:12 AM: go version >&2;
7:43:12 AM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.16.5.linux.amd64.env"
7:43:12 AM: go version go1.16.5 linux/amd64
7:43:12 AM: Detected 1 framework(s)
7:43:12 AM: "next" at version "11.1.2"
7:43:12 AM: Installing missing commands
7:43:12 AM: Verify run directory
7:43:12 AM: Section completed: initializing
7:43:14 AM: ​
7:43:14 AM:   Netlify Build                                                 
7:43:14 AM: ────────────────────────────────────────────────────────────────
7:43:14 AM: ​
7:43:14 AM: ❯ Version
7:43:14 AM:   @netlify/build 29.5.3
7:43:14 AM: ​
7:43:14 AM: ❯ Flags
7:43:14 AM:   baseRelDir: true
7:43:14 AM:   buildId: 63db1c0d7e09b2000896745f
7:43:14 AM:   deployId: 63db1c0d7e09b20008967461
7:43:14 AM: ​
7:43:14 AM: ❯ Current directory
7:43:14 AM:   /opt/build/repo/next-main
7:43:14 AM: ​
7:43:14 AM: ❯ Config file
7:43:14 AM:   /opt/build/repo/next-main/netlify.toml
7:43:14 AM: ​
7:43:14 AM: ❯ Context
7:43:14 AM:   deploy-preview
7:43:14 AM: ​
7:43:14 AM: ❯ Using Next.js Runtime - v4.30.3
7:43:15 AM: ​
7:43:15 AM:   1. @netlify/plugin-nextjs (onPreBuild event)                  
7:43:15 AM: ────────────────────────────────────────────────────────────────
7:43:15 AM: ​
7:43:15 AM: No Next.js cache to restore.
7:43:15 AM: Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed.
7:43:15 AM: ​
7:43:15 AM: (@netlify/plugin-nextjs onPreBuild completed in 19ms)
7:43:15 AM: ​
7:43:15 AM:   2. build.command from netlify.toml                            
7:43:15 AM: ────────────────────────────────────────────────────────────────
7:43:15 AM: ​
7:43:15 AM: $ yarn build
7:43:15 AM: yarn run v1.22.10
7:43:15 AM: $ next build
7:43:16 AM: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
7:43:16 AM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
7:43:16 AM: Browserslist: caniuse-lite is outdated. Please run:
7:43:16 AM: npx browserslist@latest --update-db
7:43:16 AM: Why you should do it regularly:
7:43:16 AM: https://github.com/browserslist/browserslist#browsers-data-updating
7:43:16 AM: info  - Checking validity of types...
7:43:16 AM: It looks like you're trying to use TypeScript but do not have the required package(s) installed.
7:43:16 AM: Please install @types/react by running:
7:43:16 AM: 	yarn add --dev @types/react
7:43:16 AM: If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files in your pages directory).
7:43:16 AM: error Command failed with exit code 1. (https://ntl.fyi/exit-code-1)
7:43:16 AM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
7:43:16 AM: ​
7:43:16 AM:   "build.command" failed                                        
7:43:16 AM: ────────────────────────────────────────────────────────────────
7:43:16 AM: ​
7:43:16 AM:   Error message
7:43:16 AM:   Command failed with exit code 1: yarn build (https://ntl.fyi/exit-code-1)
7:43:16 AM: ​
7:43:16 AM:   Error location
7:43:16 AM:   In build.command from netlify.toml:
7:43:16 AM:   yarn build
7:43:16 AM: ​
7:43:16 AM:   Resolved config
7:43:16 AM:   build:
7:43:16 AM:     base: /opt/build/repo/next-main
7:43:16 AM:     command: yarn build
7:43:16 AM:     commandOrigin: config
7:43:16 AM:     environment:
7:43:16 AM:       - NETLIFY_GRAPH_TOKEN
7:43:16 AM:       - NEXT_PUBLIC_DOMAIN_URL
7:43:16 AM:       - NEXT_PUBLIC_MAIN_WEBSITE
7:43:16 AM:       - NEXT_PUBLIC_RAZORPAY_KEY
7:43:16 AM:       - ONEGRAPH_AUTHLIFY_TOKEN
7:43:16 AM:       - REVIEW_ID
7:43:16 AM:       - NEXT_PRIVATE_TARGET
7:43:16 AM:     publish: /opt/build/repo/next-main/out
7:43:16 AM:     publishOrigin: config
7:43:16 AM:   plugins:
7:43:16 AM:     - inputs: {}
7:43:16 AM:       origin: config
7:43:16 AM:       package: '@netlify/plugin-nextjs'
7:43:16 AM: Caching artifacts
7:43:16 AM: Started saving node modules
7:43:16 AM: Finished saving node modules
7:43:16 AM: Started saving build plugins
7:43:16 AM: Finished saving build plugins
7:43:16 AM: Started saving yarn cache
7:43:20 AM: Finished saving yarn cache
7:43:20 AM: Started saving pip cache
7:43:20 AM: Finished saving pip cache
7:43:20 AM: Started saving emacs cask dependencies
7:43:20 AM: Finished saving emacs cask dependencies
7:43:20 AM: Started saving maven dependencies
7:43:20 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
7:43:20 AM: Finished saving maven dependencies
7:43:20 AM: Started saving boot dependencies
7:43:20 AM: Finished saving boot dependencies
7:43:20 AM: Started saving rust rustup cache
7:43:20 AM: Finished saving rust rustup cache
7:43:20 AM: Started saving go dependencies
7:43:20 AM: Finished saving go dependencies
7:43:20 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
7:43:20 AM: Failing build: Failed to build site
7:43:20 AM: Finished processing build request in 49.613s

package.json for the same:

{
  "name": "wyzr-main-website",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev -p 3003",
    "start": "next start",
    "lint": "eslint ./ --ignore-path .gitignore",
    "lint:fix": "npm run lint -- --fix",
    "build": "next build",
    "build:prod": "next build && next export && rm -rf node_modules"
  },
  "dependencies": {
    "@chakra-ui/icons": "^2.0.17",
    "@chakra-ui/react": "^2.4.9",
    "@emotion/react": "^11.10.5",
    "@emotion/styled": "^11.10.5",
    "@microsoft/applicationinsights-react-js": "^3.4.0",
    "@microsoft/applicationinsights-web": "^2.8.9",
    "@netlify/plugin-nextjs": "^4.30.3",
    "axios": "^1.3.1",
    "file-saver": "^2.0.5",
    "formik": "^2.2.9",
    "framer-motion": "^9.0.0",
    "history": "^5.3.0",
    "js-file-download": "^0.4.12",
    "next": "latest",
    "next-auth": "^4.19.2",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-icons": "^4.7.1",
    "react-responsive-carousel": "^3.2.23",
    "react-tweet-embed": "^2.0.0",
    "swiper": "^9.0.0"
  },
  "devDependencies": {
    "@types/file-saver": "^2.0.5",
    "@types/history": "^4.7.11",
    "@typescript-eslint/eslint-plugin": "^5.50.0",
    "@typescript-eslint/parser": "^5.50.0",
    "critters": "^0.0.16",
    "eslint": "^8.33.0",
    "eslint-config-next": "^13.1.6",
    "eslint-plugin-react": "^7.32.2",
    "file-loader": "^6.2.0",
    "typescript": "^4.9.5"
  }
}

@AdityaNair102001 Does this provide any pointers…

I mean I know this is where the problem is, and I tried the following but none of them worked:

  1. Error saying typescript not installed (but it is) - #6 by coelmay
  2. javascript - Next.js TypeScript Error: You do not have the required packages installed - Stack Overflow

When you say you tried them, what did you try?

One odd thing I see is this:

Version in your package.json…

    "next": "latest",

latest is 13.1.6

Version the build is showing…

7:43:12 AM: "next" at version "11.1.2"

Exactly! I was wondering the same why’s that happening

The server is likely going from your lock files, so your package-lock.json / yarn.lock.

You should make sure they’re up-to-date.

There’s also this warning:

7:42:46 AM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
1 Like

Hi @nathanmartin , you were correct, the server was using yarn.lock to install the packages, meanwhile I was installing the packages using npm. Deleted yarn.lock and redeploying with necessary packages solved the issue for me. I had to do npm install @types/node to solve the typescript error. Thanks a lot for your time and assistance.

hi @AdityaNair102001 :wave:t6: thanks so much for sharing this solution with the community.