title: Cannot deploy Next.js to Netlify. Deploy failed due to an error in @netlify/plugin-nextjs plugin
body: <p>I can run <code>npm run build</code> with no problems at all, but whenever I try and deploy my Next.js project to Netlify I get an odd error stating <code>Deploy failed due to an error in @netlify/plugin-nextjs plugin</code></p>
  <p>After doing some research I found that I should install <code>@netlify/plugin-nextjs</code> into my package.json as a dev dependency, then add it to a netlify.toml in the root of my project which I have done. Here is the github repo which Netlify's support forums have led me to: <a href="https://github.com/netlify/netlify-plugin-nextjs" rel="nofollow noreferrer">https://github.com/netlify/netlify-plugin-nextjs</a></p>
  <p>I've followed the directions on their github repo above for the @netlify/plugin-nextjs plugin as well as searched for any relevant posts under their github issues and unfortunately I couldn’t find anything related nor useful in the github issues.</p>
  <p>I’ve tried clearing cache and deploy but it didn’t help.</p>
  <p>I am using Next.js version v11.1.2</p>
  <p>Here is the build log with the error detailed:</p>
  <pre><code>11:58:50 PM: Started restoring cached go cache
  11:58:50 PM: Finished restoring cached go cache
  11:58:50 PM: go version go1.16.5 linux/amd64
  11:58:50 PM: go version go1.16.5 linux/amd64
  11:58:50 PM: Installing missing commands
  11:58:50 PM: Verify run directory
  11:58:52 PM: ​
  11:58:52 PM: ────────────────────────────────────────────────────────────────
  11:58:52 PM:   Netlify Build                                                 
  11:58:52 PM: ────────────────────────────────────────────────────────────────
  11:58:52 PM: ​
  11:58:52 PM: ❯ Version
  11:58:52 PM:   @netlify/build 18.21.2
  11:58:52 PM: ​
  11:58:52 PM: ❯ Flags
  11:58:52 PM:   baseRelDir: true
  11:58:52 PM:   buildId: 618232a9499e9a000783387d
  11:58:52 PM:   deployId: 618232a9499e9a000783387f
  11:58:52 PM: ​
  11:58:52 PM: ❯ Current directory
  11:58:52 PM:   /opt/build/repo
  11:58:52 PM: ​
  11:58:52 PM: ❯ Config file
  11:58:52 PM:   /opt/build/repo/netlify.toml
  11:58:52 PM: ​
  11:58:52 PM: ❯ Context
  11:58:52 PM:   production
  11:58:52 PM: ​
  11:58:52 PM: ❯ Installing plugins
  11:58:52 PM:    - @netlify/plugin-nextjs@3.9.2
  11:59:02 PM: ​
  11:59:02 PM: ❯ Loading plugins
  11:59:02 PM:    - @netlify/plugin-nextjs@3.9.2 from netlify.toml
  11:59:03 PM: ​
  11:59:03 PM: ────────────────────────────────────────────────────────────────
  11:59:03 PM:   1. @netlify/plugin-nextjs (onPreBuild event)                  
  11:59:03 PM: ────────────────────────────────────────────────────────────────
  11:59:03 PM: ​
  11:59:03 PM: ​
  11:59:03 PM: ────────────────────────────────────────────────────────────────
  11:59:03 PM:   Plugin &quot;@netlify/plugin-nextjs&quot; failed                        
  11:59:03 PM: ────────────────────────────────────────────────────────────────
  11:59:03 PM: ​
  11:59:03 PM:   Error message
  11:59:03 PM:   Error: This site does not seem to be using Next.js. Please run &quot;npm install next&quot; in the repository.
  11:59:03 PM:   If you are using a monorepo, please see the docs on configuring your site: https://ntl.fyi/next-monorepos
  11:59:03 PM: ​
  11:59:03 PM:   Plugin details
  11:59:03 PM:   Package:        @netlify/plugin-nextjs
  11:59:03 PM:   Version:        3.9.2
  11:59:03 PM:   Repository:     git+https://github.com/netlify/netlify-plugin-nextjs.git
  11:59:03 PM:   npm link:       https://www.npmjs.com/package/@netlify/plugin-nextjs
  11:59:03 PM:   Report issues:  https://github.com/netlify/netlify-plugin-nextjs/issues
  11:59:03 PM: ​
  11:59:03 PM:   Error location
  11:59:03 PM:   In &quot;onPreBuild&quot; event in &quot;@netlify/plugin-nextjs&quot; from netlify.toml
  11:59:03 PM:       at validateNextUsage (/.netlify/plugins/node_modules/@netlify/plugin-nextjs/helpers/validateNextUsage.js:15:12)
  11:59:03 PM:       at onPreBuild (/.netlify/plugins/node_modules/@netlify/plugin-nextjs/index.js:32:5)
  11:59:03 PM: ​
  11:59:03 PM:   Resolved config
  11:59:03 PM:   build:
  11:59:03 PM:     command: next build
  11:59:03 PM:     commandOrigin: config
  11:59:03 PM:     environment:
  11:59:03 PM:       - FACEBOOK_APP_ID
  11:59:03 PM:       - FACEBOOK_APP_SECRET
  11:59:03 PM:       - GATSBY_STRIPE_PK
  11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_API_KEY
  11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_APPID
  11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
  11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_DATABASE_URL
  11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID
  11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_PROJECT_ID
  11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET
  11:59:03 PM:       - NEXT_PUBLIC_STRAPI
  11:59:03 PM:       - NEXT_PUBLIC_STRAPI_DEV
  11:59:03 PM:       - NEXT_PUBLIC_STRAPI_FETCH
  11:59:03 PM:       - NEXT_PUBLIC_STRAPI_PROD
  11:59:03 PM:       - STRAPI_API
  11:59:03 PM:       - CYPRESS_CACHE_FOLDER
  11:59:03 PM:     ignore: git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../
  11:59:03 PM:     publish: /opt/build/repo/.next
  11:59:03 PM:     publishOrigin: config
  11:59:03 PM:   plugins:
  11:59:03 PM:     - inputs: {}
  11:59:03 PM:       origin: config
  11:59:03 PM:       package: '@netlify/plugin-nextjs'
  11:59:04 PM: Caching artifacts
  11:59:04 PM: Started saving node modules
  11:59:04 PM: Finished saving node modules
  11:59:04 PM: Started saving build plugins
  11:59:04 PM: Finished saving build plugins
  11:59:04 PM: Started saving yarn cache
  11:59:29 PM: Finished saving yarn cache
  11:59:29 PM: Started saving pip cache
  11:59:29 PM: Finished saving pip cache
  11:59:29 PM: Started saving emacs cask dependencies
  11:59:29 PM: Finished saving emacs cask dependencies
  </code></pre>
  <p>Here is my package.json file:</p>
  <pre><code>{
    &quot;name&quot;: &quot;@minimal/minimal-kit-react&quot;,
    &quot;author&quot;: &quot;minimals.cc&quot;,
    &quot;version&quot;: &quot;2.6.0&quot;,
    &quot;private&quot;: true,
    &quot;scripts&quot;: {
      &quot;dev&quot;: &quot;next dev -p 3222&quot;,
      &quot;build&quot;: &quot;next build&quot;,
      &quot;start&quot;: &quot;next start&quot;
    },
    &quot;dependencies&quot;: {
      &quot;@apollo/client&quot;: &quot;^3.4.16&quot;,
      &quot;@auth0/auth0-spa-js&quot;: &quot;1.18&quot;,
      &quot;@emotion/cache&quot;: &quot;^11.4.0&quot;,
      &quot;@emotion/react&quot;: &quot;^11.4.1&quot;,
      &quot;@emotion/server&quot;: &quot;^11.4.0&quot;,
      &quot;@emotion/styled&quot;: &quot;^11.3.0&quot;,
      &quot;@fontsource/alata&quot;: &quot;^4.5.0&quot;,
      &quot;@fontsource/barlow&quot;: &quot;^4.5.0&quot;,
      &quot;@fontsource/inter&quot;: &quot;^4.5.0&quot;,
      &quot;@fontsource/karla&quot;: &quot;^4.5.0&quot;,
      &quot;@fontsource/poppins&quot;: &quot;^4.5.0&quot;,
      &quot;@fontsource/public-sans&quot;: &quot;^4.5.0&quot;,
      &quot;@fontsource/raleway&quot;: &quot;^4.5.0&quot;,
      &quot;@fullcalendar/daygrid&quot;: &quot;^5.9.0&quot;,
      &quot;@fullcalendar/interaction&quot;: &quot;^5.9.0&quot;,
      &quot;@fullcalendar/list&quot;: &quot;^5.9.0&quot;,
      &quot;@fullcalendar/react&quot;: &quot;^5.9.0&quot;,
      &quot;@fullcalendar/timegrid&quot;: &quot;^5.9.0&quot;,
      &quot;@fullcalendar/timeline&quot;: &quot;^5.9.0&quot;,
      &quot;@hookform/devtools&quot;: &quot;^4.0.1&quot;,
      &quot;@hookform/resolvers&quot;: &quot;^2.8.0&quot;,
      &quot;@iconify/icons-ant-design&quot;: &quot;^1.1.0&quot;,
      &quot;@iconify/icons-eva&quot;: &quot;^1.1.0&quot;,
      &quot;@iconify/icons-ic&quot;: &quot;^1.1.10&quot;,
      &quot;@iconify/icons-simple-icons&quot;: &quot;^1.1.46&quot;,
      &quot;@material-ui/core&quot;: &quot;^4.11.0&quot;,
      &quot;@material-ui/data-grid&quot;: &quot;^4.0.0-alpha.21&quot;,
      &quot;@material-ui/icons&quot;: &quot;^4.11.2&quot;,
      &quot;@material-ui/lab&quot;: &quot;^4.0.0-alpha.56&quot;,
      &quot;@mui/icons-material&quot;: &quot;^5.0.0&quot;,
      &quot;@mui/lab&quot;: &quot;^5.0.0-alpha.47&quot;,
      &quot;@mui/material&quot;: &quot;^5.0.0&quot;,
      &quot;@mui/styles&quot;: &quot;^5.0.0&quot;,
      &quot;@mui/utils&quot;: &quot;^5.0.0&quot;,
      &quot;@mui/x-data-grid&quot;: &quot;^5.0.0-beta.1&quot;,
      &quot;@react-pdf/renderer&quot;: &quot;^2.0.19&quot;,
      &quot;@reduxjs/toolkit&quot;: &quot;^1.6.1&quot;,
      &quot;@stripe/react-stripe-js&quot;: &quot;^1.5.0&quot;,
      &quot;@stripe/stripe-js&quot;: &quot;^1.18.0&quot;,
      &quot;@testing-library/jest-dom&quot;: &quot;^5.14.1&quot;,
      &quot;@testing-library/react&quot;: &quot;^12.1.0&quot;,
      &quot;@testing-library/user-event&quot;: &quot;^13.2.1&quot;,
      &quot;@turf/bbox&quot;: &quot;^6.5.0&quot;,
      &quot;amazon-cognito-identity-js&quot;: &quot;^5.1.0&quot;,
      &quot;animejs&quot;: &quot;^3.2.1&quot;,
      &quot;apexcharts&quot;: &quot;^3.28.3&quot;,
      &quot;autosuggest-highlight&quot;: &quot;^3.1.1&quot;,
      &quot;axios&quot;: &quot;^0.21.4&quot;,
      &quot;axios-mock-adapter&quot;: &quot;^1.20.0&quot;,
      &quot;change-case&quot;: &quot;^4.1.2&quot;,
      &quot;d3-array&quot;: &quot;^3.0.2&quot;,
      &quot;d3-scale&quot;: &quot;^4.0.0&quot;,
      &quot;date-fns&quot;: &quot;^2.24.0&quot;,
      &quot;deck.gl&quot;: &quot;^8.5.8&quot;,
      &quot;dotenv&quot;: &quot;^10.0.0&quot;,
      &quot;draft-js&quot;: &quot;^0.11.7&quot;,
      &quot;draftjs-to-html&quot;: &quot;^0.9.1&quot;,
      &quot;emoji-mart&quot;: &quot;^3.0.0&quot;,
      &quot;firebase&quot;: &quot;^8.10.0&quot;,
      &quot;formik&quot;: &quot;^2.2.9&quot;,
      &quot;framer-motion&quot;: &quot;^4.1.17&quot;,
      &quot;fs&quot;: &quot;^0.0.1-security&quot;,
      &quot;graphql&quot;: &quot;^15.7.1&quot;,
      &quot;highlight.js&quot;: &quot;^11.3.1&quot;,
      &quot;history&quot;: &quot;^5.0.1&quot;,
      &quot;i18next&quot;: &quot;^20.6.1&quot;,
      &quot;i18next-browser-languagedetector&quot;: &quot;^6.1.2&quot;,
      &quot;immutable&quot;: &quot;^4.0.0-rc.14&quot;,
      &quot;jsonwebtoken&quot;: &quot;^8.5.1&quot;,
      &quot;jwt-decode&quot;: &quot;^3.1.2&quot;,
      &quot;lazysizes&quot;: &quot;^5.3.2&quot;,
      &quot;lodash&quot;: &quot;^4.17.21&quot;,
      &quot;lowlight&quot;: &quot;^2.4.0&quot;,
      &quot;madge&quot;: &quot;^5.0.1&quot;,
      &quot;mapbox-gl&quot;: &quot;^2.4.1&quot;,
      &quot;next&quot;: &quot;^11.1.2&quot;,
      &quot;notistack&quot;: &quot;^1.0.6-next.3&quot;,
      &quot;nprogress&quot;: &quot;^0.2.0&quot;,
      &quot;numeral&quot;: &quot;^2.0.6&quot;,
      &quot;pnp-webpack-plugin&quot;: &quot;^1.7.0&quot;,
      &quot;process&quot;: &quot;^0.11.10&quot;,
      &quot;prop-types&quot;: &quot;^15.7.2&quot;,
      &quot;react&quot;: &quot;17.0.2&quot;,
      &quot;react-apexcharts&quot;: &quot;^1.3.9&quot;,
      &quot;react-beautiful-dnd&quot;: &quot;^13.1.0&quot;,
      &quot;react-copy-to-clipboard&quot;: &quot;^5.0.4&quot;,
      &quot;react-dom&quot;: &quot;17.0.2&quot;,
      &quot;react-draft-wysiwyg&quot;: &quot;^1.14.7&quot;,
      &quot;react-dropzone&quot;: &quot;^11.4.0&quot;,
      &quot;react-helmet-async&quot;: &quot;^1.1.2&quot;,
      &quot;react-highlight&quot;: &quot;^0.14.0&quot;,
      &quot;react-hook-form&quot;: &quot;^7.15.3&quot;,
      &quot;react-i18next&quot;: &quot;^11.12.0&quot;,
      &quot;react-image-lightbox&quot;: &quot;^5.1.4&quot;,
      &quot;react-infinite-scroll-component&quot;: &quot;^6.1.0&quot;,
      &quot;react-intersection-observer&quot;: &quot;^8.32.1&quot;,
      &quot;react-lottie&quot;: &quot;^1.2.3&quot;,
      &quot;react-map-gl&quot;: &quot;^6.1.17&quot;,
      &quot;react-markdown&quot;: &quot;^7.1.0&quot;,
      &quot;react-quill&quot;: &quot;^2.0.0-beta.4&quot;,
      &quot;react-redux&quot;: &quot;^7.2.5&quot;,
      &quot;react-resize-aware&quot;: &quot;^3.1.1&quot;,
      &quot;react-scripts&quot;: &quot;^4.0.1&quot;,
      &quot;react-scroll&quot;: &quot;^1.8.4&quot;,
      &quot;react-slick&quot;: &quot;^0.28.0&quot;,
      &quot;react-spring&quot;: &quot;^9.2.4&quot;,
      &quot;redux&quot;: &quot;^4.1.1&quot;,
      &quot;redux-persist&quot;: &quot;^6.0.0&quot;,
      &quot;rehype-highlight&quot;: &quot;^5.0.0&quot;,
      &quot;rehype-raw&quot;: &quot;^6.1.0&quot;,
      &quot;simplebar&quot;: &quot;^5.3.5&quot;,
      &quot;simplebar-react&quot;: &quot;^2.3.5&quot;,
      &quot;slick-carousel&quot;: &quot;^1.8.1&quot;,
      &quot;stylis&quot;: &quot;^4.0.10&quot;,
      &quot;stylis-plugin-rtl&quot;: &quot;^2.0.2&quot;,
      &quot;typescript&quot;: &quot;^4.3.5&quot;,
      &quot;uuid&quot;: &quot;^8.3.2&quot;,
      &quot;worker-loader&quot;: &quot;^3.0.8&quot;,
      &quot;yup&quot;: &quot;^0.32.9&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@babel/core&quot;: &quot;^7.15.8&quot;,
      &quot;@babel/eslint-parser&quot;: &quot;^7.15.4&quot;,
      &quot;@babel/preset-react&quot;: &quot;^7.14.5&quot;,
      &quot;@iconify/icons-fa-solid&quot;: &quot;^1.1.1&quot;,
      &quot;@iconify/react&quot;: &quot;^3.0.1&quot;,
      &quot;@netlify/plugin-nextjs&quot;: &quot;^4.0.0-beta.5&quot;,
      &quot;@types/node&quot;: &quot;^16.7.13&quot;,
      &quot;@typescript-eslint/eslint-plugin&quot;: &quot;^4.31.0&quot;,
      &quot;@typescript-eslint/parser&quot;: &quot;^4.31.0&quot;,
      &quot;eslint&quot;: &quot;^7.32.0&quot;,
      &quot;eslint-config-airbnb&quot;: &quot;^18.2.1&quot;,
      &quot;eslint-config-airbnb-typescript&quot;: &quot;^14.0.0&quot;,
      &quot;eslint-config-prettier&quot;: &quot;^8.3.0&quot;,
      &quot;eslint-config-wesbos&quot;: &quot;2.1.0&quot;,
      &quot;eslint-plugin-html&quot;: &quot;^6.1.2&quot;,
      &quot;eslint-plugin-import&quot;: &quot;^2.24.2&quot;,
      &quot;eslint-plugin-jsx-a11y&quot;: &quot;^6.4.1&quot;,
      &quot;eslint-plugin-prettier&quot;: &quot;^4.0.0&quot;,
      &quot;eslint-plugin-react&quot;: &quot;^7.25.1&quot;,
      &quot;eslint-plugin-react-hooks&quot;: &quot;^4.2.0&quot;,
      &quot;graphql&quot;: &quot;latest&quot;,
      &quot;prettier&quot;: &quot;^2.3.2&quot;,
      &quot;typescript&quot;: &quot;^4.4.2&quot;
    }
  }
  
  </code></pre>
  <p>Here is my netlify.toml:</p>
  <pre><code>[build]
  publish = &quot;.next&quot;
  
  [[plugins]]
  package = &quot;@netlify/plugin-nextjs&quot;
  
  </code></pre>