Module not found: Error: Can't resolve 'jsonwebtoken' in '/opt/build/repo/server/utils'

Sitename: www.wyzr.in
I got a build error while deploying my next application on preview.
Build log:

12:08:16 AM: build-image version: 1ca34a93198b041e44214013884c57d146a23fed (focal)
12:08:16 AM: build-image tag: v4.16.4
12:08:16 AM: buildbot version: 5d70ebdb976733297fb4c90b41002389a248e2df
12:08:16 AM: Fetching cached dependencies
12:08:17 AM: Starting to download cache of 499.6MB
12:08:22 AM: Finished downloading cache in 4.974s
12:08:22 AM: Starting to extract cache
12:08:24 AM: Finished extracting cache in 2.293s
12:08:24 AM: Finished fetching cache in 7.336s
12:08:24 AM: Starting to prepare the repo for build
12:08:24 AM: Preparing Git Reference pull/21/head
12:08:25 AM: Parsing package.json dependencies
12:08:26 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'next-main/out' versus '' in the Netlify UI
12:08:27 AM: Starting build script
12:08:27 AM: Installing dependencies
12:08:27 AM: Python version set to 2.7
12:08:27 AM: Started restoring cached Node.js version
12:08:27 AM: Finished restoring cached Node.js version
12:08:28 AM: v16.19.0 is already installed.
12:08:28 AM: Now using node v16.19.0 (npm v8.19.3)
12:08:28 AM: Enabling Node.js Corepack
12:08:28 AM: Started restoring cached build plugins
12:08:28 AM: Finished restoring cached build plugins
12:08:28 AM: Attempting Ruby version 2.7.2, read from environment
12:08:29 AM: Using Ruby version 2.7.2
12:08:29 AM: Using PHP version 8.0
12:08:29 AM: Started restoring cached corepack dependencies
12:08:29 AM: mv: cannot move '/opt/build/cache/.node/corepack' to '/opt/buildhome/.node/corepack': No such file or directory
12:08:29 AM: Finished restoring cached corepack dependencies
12:08:29 AM: Started restoring cached yarn cache
12:08:30 AM: Finished restoring cached yarn cache
12:08:30 AM: Installing Yarn version 1.22.10
12:08:30 AM: Preparing yarn@1.22.10 for immediate activation...
12:08:31 AM: No yarn workspaces detected
12:08:31 AM: Started restoring cached node modules
12:08:31 AM: Finished restoring cached node modules
12:08:31 AM: Installing npm packages using Yarn version 1.22.10
12:08:31 AM: yarn install v1.22.10
12:08:31 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.
12:08:31 AM: [1/4] Resolving packages...
12:08:32 AM: [2/4] Fetching packages...
12:08:33 AM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
12:08:33 AM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
12:08:33 AM: info @next/swc-darwin-x64@11.1.2: The platform "linux" is incompatible with this module.
12:08:33 AM: info "@next/swc-darwin-x64@11.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
12:08:33 AM: info @next/swc-win32-x64-msvc@11.1.2: The platform "linux" is incompatible with this module.
12:08:33 AM: info "@next/swc-win32-x64-msvc@11.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
12:08:33 AM: info @next/swc-darwin-arm64@11.1.2: The platform "linux" is incompatible with this module.
12:08:33 AM: info "@next/swc-darwin-arm64@11.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
12:08:33 AM: info @next/swc-darwin-arm64@11.1.2: The CPU architecture "x64" is incompatible with this module.
12:08:33 AM: [3/4] Linking dependencies...
12:08:33 AM: warning " > @chakra-ui/icons@1.0.13" has unmet peer dependency "@chakra-ui/system@>=1.0.0".
12:08:33 AM: warning "@chakra-ui/icons > @chakra-ui/icon@1.1.9" has unmet peer dependency "@chakra-ui/system@>=1.0.0".
12:08:33 AM: warning "@emotion/styled > @emotion/babel-plugin@11.3.0" has unmet peer dependency "@babel/core@^7.0.0".
12:08:33 AM: warning "@emotion/styled > @emotion/babel-plugin > @babel/plugin-syntax-jsx@7.14.5" has unmet peer dependency "@babel/core@^7.0.0-0".
12:08:33 AM: warning " > next-auth@4.19.0" has incorrect peer dependency "next@^12.2.5 || ^13".
12:08:33 AM: warning " > file-loader@6.2.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
12:08:34 AM: [4/4] Building fresh packages...
12:08:34 AM: success Saved lockfile.
12:08:34 AM: Done in 2.99s.
12:08:34 AM: npm packages installed using Yarn
12:08:34 AM: Started restoring cached go cache
12:08:34 AM: Finished restoring cached go cache
12:08:34 AM: Installing Go version 1.16.5 (requested 1.16.5)
12:08:38 AM: unset GOOS;
12:08:38 AM: unset GOARCH;
12:08:38 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64';
12:08:38 AM: export PATH="/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64/bin:${PATH}";
12:08:38 AM: go version >&2;
12:08:38 AM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.16.5.linux.amd64.env"
12:08:38 AM: go version go1.16.5 linux/amd64
12:08:39 AM: Detected 1 framework(s)
12:08:39 AM: "next" at version "11.1.2"
12:08:39 AM: Installing missing commands
12:08:39 AM: Verify run directory
12:08:39 AM: Section completed: initializing
12:08:40 AM: ​
12:08:40 AM:   Netlify Build                                                 
12:08:40 AM: ────────────────────────────────────────────────────────────────
12:08:40 AM: ​
12:08:40 AM: ❯ Version
12:08:40 AM:   @netlify/build 29.5.1
12:08:40 AM: ​
12:08:40 AM: ❯ Flags
12:08:40 AM:   baseRelDir: true
12:08:40 AM:   buildId: 63d80e9772810100089552ae
12:08:40 AM:   deployId: 63d80e9772810100089552b0
12:08:40 AM: ​
12:08:40 AM: ❯ Current directory
12:08:40 AM:   /opt/build/repo/next-main
12:08:40 AM: ​
12:08:40 AM: ❯ Config file
12:08:40 AM:   /opt/build/repo/next-main/netlify.toml
12:08:40 AM: ​
12:08:40 AM: ❯ Context
12:08:40 AM:   deploy-preview
12:08:40 AM: ​
12:08:40 AM: ❯ Using Next.js Runtime - v3.9.0
12:08:40 AM: ​
12:08:40 AM: ❯ Outdated plugins
12:08:40 AM:    - @netlify/plugin-nextjs@3.9.0: latest version is 4.30.1
12:08:40 AM:      To upgrade this plugin, please update its version in "package.json"
12:08:41 AM: ​
12:08:41 AM:   1. @netlify/plugin-nextjs (onPreBuild event)                  
12:08:41 AM: ────────────────────────────────────────────────────────────────
12:08:41 AM: ​
12:08:41 AM: Using Next.js 11.1.2
12:08:41 AM: Warning: support for Next.js >=11.1.0 is experimental
12:08:42 AM: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
12:08:42 AM: The "target" config property must be one of "serverless", "experimental-serverless-trace". Building with "serverless" target.
12:08:42 AM: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
12:08:42 AM: Next.js cache restored.
12:08:42 AM: ​
12:08:42 AM: (@netlify/plugin-nextjs onPreBuild completed in 736ms)
12:08:42 AM: ​
12:08:42 AM:   2. build.command from netlify.toml                            
12:08:42 AM: ────────────────────────────────────────────────────────────────
12:08:42 AM: ​
12:08:42 AM: $ yarn build
12:08:42 AM: yarn run v1.22.10
12:08:42 AM: $ next build
12:08:43 AM: info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
12:08:43 AM: Browserslist: caniuse-lite is outdated. Please run:
12:08:43 AM: npx browserslist@latest --update-db
12:08:43 AM: Why you should do it regularly:
12:08:43 AM: https://github.com/browserslist/browserslist#browsers-data-updating
12:08:43 AM: info  - Checking validity of types...
12:08:53 AM: ./src/components/BookCard.tsx
12:08:53 AM: 26:60  Warning: 'expectedRelease' is defined but never used.  no-unused-vars
12:08:53 AM: ./src/components/Gift/AddEmailForm.tsx
12:08:53 AM: 5:40  Warning: 'link' is defined but never used.  no-unused-vars
12:08:53 AM: ./src/components/Gift/OrderDetails.tsx
12:08:53 AM: 50:6  Warning: React Hook useEffect has a missing dependency: 'planPrice'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
12:08:53 AM: ./src/components/Gift/PlansCount.tsx
12:08:53 AM: 5:120  Warning: 'getNonExistingUserState' is defined but never used.  no-unused-vars
12:08:53 AM: 5:144  Warning: 'getNonExistingUserCity' is defined but never used.  no-unused-vars
12:08:53 AM: ./src/components/Navbar/Logo.tsx
12:08:53 AM: 7:11  Warning: 'iconColor' is assigned a value but never used.  no-unused-vars
12:08:53 AM: ./src/components/Navbar/Navbar.tsx
12:08:53 AM: 68:21  Warning: Do not use <img>. Use Image from 'next/image' instead. See https://nextjs.org/docs/messages/no-img-element.  @next/next/no-img-element
12:08:53 AM: ./src/components/PricingCard.tsx
12:08:53 AM: 52:5  Warning: 'description' is assigned a value but never used.  no-unused-vars
12:08:53 AM: 61:10  Warning: 'isModalOpen' is assigned a value but never used.  no-unused-vars
12:08:53 AM: 61:23  Warning: 'setIsModalOpen' is assigned a value but never used.  no-unused-vars
12:08:53 AM: info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
12:08:53 AM: info  - Creating an optimized production build...
12:08:54 AM: Browserslist: caniuse-lite is outdated. Please run:
12:08:54 AM: npx browserslist@latest --update-db
12:08:54 AM: Why you should do it regularly:
12:08:54 AM: https://github.com/browserslist/browserslist#browsers-data-updating
12:08:57 AM: Failed to compile.
12:08:57 AM: 
12:08:57 AM: ModuleNotFoundError: Module not found: Error: Can't resolve 'jsonwebtoken' in '/opt/build/repo/server/utils'
12:08:57 AM: > Build error occurred
12:08:57 AM: Error: > Build failed because of webpack errors
12:08:57 AM:     at /opt/build/repo/next-main/node_modules/next/dist/build/index.js:397:19
12:08:57 AM:     at async Span.traceAsyncFn (/opt/build/repo/next-main/node_modules/next/dist/telemetry/trace/trace.js:60:20)
12:08:57 AM:     at async Object.build [as default] (/opt/build/repo/next-main/node_modules/next/dist/build/index.js:77:25)
12:08:57 AM: error Command failed with exit code 1.
12:08:57 AM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
12:08:57 AM: ​
12:08:57 AM:   "build.command" failed                                        
12:08:57 AM: ────────────────────────────────────────────────────────────────
12:08:57 AM: ​
12:08:57 AM:   Error message
12:08:57 AM:   Command failed with exit code 1: yarn build
12:08:57 AM: ​
12:08:57 AM:   Error location
12:08:57 AM:   In build.command from netlify.toml:
12:08:57 AM:   yarn build
12:08:57 AM: ​
12:08:57 AM:   Resolved config
12:08:57 AM:   build:
12:08:57 AM:     base: /opt/build/repo/next-main
12:08:57 AM:     command: yarn build
12:08:57 AM:     commandOrigin: config
12:08:57 AM:     environment:
12:08:57 AM:       - NETLIFY_GRAPH_TOKEN
12:08:57 AM:       - NEXT_PUBLIC_DOMAIN_URL
12:08:57 AM:       - NEXT_PUBLIC_MAIN_WEBSITE
12:08:57 AM:       - NEXT_PUBLIC_RAZORPAY_KEY
12:08:57 AM:       - ONEGRAPH_AUTHLIFY_TOKEN
12:08:57 AM:       - REVIEW_ID
12:08:57 AM:     publish: /opt/build/repo/next-main/out
12:08:57 AM:     publishOrigin: config
12:08:57 AM:   plugins:
12:08:57 AM:     - inputs: {}
12:08:57 AM:       origin: config
12:08:57 AM:       package: '@netlify/plugin-nextjs'
12:08:58 AM: Caching artifacts
12:08:58 AM: Started saving node modules
12:08:58 AM: Finished saving node modules
12:08:58 AM: Started saving build plugins
12:08:58 AM: Finished saving build plugins
12:08:58 AM: Started saving yarn cache
12:08:59 AM: Finished saving yarn cache
12:08:59 AM: Started saving pip cache
12:08:59 AM: Finished saving pip cache
12:08:59 AM: Started saving emacs cask dependencies
12:08:59 AM: Finished saving emacs cask dependencies
12:08:59 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
12:08:59 AM: Started saving maven dependencies
12:08:59 AM: Finished saving maven dependencies
12:08:59 AM: Started saving boot dependencies
12:08:59 AM: Finished saving boot dependencies
12:08:59 AM: Started saving rust rustup cache
12:08:59 AM: Finished saving rust rustup cache
12:08:59 AM: Started saving go dependencies
12:08:59 AM: Finished saving go dependencies
12:08:59 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:08:59 AM: Failing build: Failed to build site
12:09:00 AM: Finished processing build request in 43.19s

I’m getting the following error while deploying my site. I am using next12.2.2. I have breaking changes in nePreformatted textxt13, hence using next12. Please help me find whats wrong. Here is my package.json:

{
 "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": "^3.9.0",
   "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": "^17.0.2",
   "react-dom": "^17.0.2",
   "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"
 }
}

@AdityaNair102001 Are you using jsonwebtoken?

Because I don’t see it defined as a dependency in your package.json?

Hi @nathanmartin, I was using jsonwebtoken in my server folder, which I imported in my nextjs UI folder(we have a monolithic architecture). I have resolved that error, updated all my packages to the latest version, and retried the deployment. This time, it’s throwing some other error:

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

This is my latest package.json:

{
  "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"
  }
}

I think it is related to next-auth. Can you please take a look?

@AdityaNair102001 Excellent, glad I could solve that one.

Your new error I’ve basically got no idea, as I don’t use Next, nor TypeScript.

The relevant part is this:

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 {

You might want to make a new thread with it, so the title at least matches the request.

Okay sure, thank you for your time.