无法将 Next.js 部署到 Netlify。由于 @netlify/plugin-nextjs 插件中的错误,部署失败

lea*_*710 6 netlify next.js

我可以npm run build毫无问题地运行,但每当我尝试将 Next.js 项目部署到 Netlify 时,我都会收到一个奇怪的错误,指出Deploy failed due to an error in @netlify/plugin-nextjs plugin

\n

经过一些研究后,我发现我应该将其@netlify/plugin-nextjs作为开发依赖项安装到 package.json 中,然后将其添加到我已完成的项目根目录中的 netlify.toml 中。这是 Netlify 支持论坛引导我找到的 github 存储库: https: //github.com/netlify/netlify-plugin-nextjs

\n

我已经按照上面他们的 github 存储库上的 @netlify/plugin-nextjs 插件的说明进行操作,并在他们的 github issues 下搜索了任何相关帖子,不幸的是,我无法\xe2\x80\x99 在 中找到任何相关或有用的内容。 github问题。

\n

我\xe2\x80\x99已尝试清除缓存并部署,但它没有\xe2\x80\x99帮助。

\n

我使用的是 Next.js 版本 v11.1.2

\n

这是包含详细错误的构建日志:

\n
11:58:50 PM: Started restoring cached go cache\n11:58:50 PM: Finished restoring cached go cache\n11:58:50 PM: go version go1.16.5 linux/amd64\n11:58:50 PM: go version go1.16.5 linux/amd64\n11:58:50 PM: Installing missing commands\n11:58:50 PM: Verify run directory\n11:58:52 PM: \xe2\x80\x8b\n11:58:52 PM: \xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n11:58:52 PM:   Netlify Build                                                 \n11:58:52 PM: \xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n11:58:52 PM: \xe2\x80\x8b\n11:58:52 PM: \xe2\x9d\xaf Version\n11:58:52 PM:   @netlify/build 18.21.2\n11:58:52 PM: \xe2\x80\x8b\n11:58:52 PM: \xe2\x9d\xaf Flags\n11:58:52 PM:   baseRelDir: true\n11:58:52 PM:   buildId: 618232a9499e9a000783387d\n11:58:52 PM:   deployId: 618232a9499e9a000783387f\n11:58:52 PM: \xe2\x80\x8b\n11:58:52 PM: \xe2\x9d\xaf Current directory\n11:58:52 PM:   /opt/build/repo\n11:58:52 PM: \xe2\x80\x8b\n11:58:52 PM: \xe2\x9d\xaf Config file\n11:58:52 PM:   /opt/build/repo/netlify.toml\n11:58:52 PM: \xe2\x80\x8b\n11:58:52 PM: \xe2\x9d\xaf Context\n11:58:52 PM:   production\n11:58:52 PM: \xe2\x80\x8b\n11:58:52 PM: \xe2\x9d\xaf Installing plugins\n11:58:52 PM:    - @netlify/plugin-nextjs@3.9.2\n11:59:02 PM: \xe2\x80\x8b\n11:59:02 PM: \xe2\x9d\xaf Loading plugins\n11:59:02 PM:    - @netlify/plugin-nextjs@3.9.2 from netlify.toml\n11:59:03 PM: \xe2\x80\x8b\n11:59:03 PM: \xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n11:59:03 PM:   1. @netlify/plugin-nextjs (onPreBuild event)                  \n11:59:03 PM: \xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n11:59:03 PM: \xe2\x80\x8b\n11:59:03 PM: \xe2\x80\x8b\n11:59:03 PM: \xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n11:59:03 PM:   Plugin "@netlify/plugin-nextjs" failed                        \n11:59:03 PM: \xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n11:59:03 PM: \xe2\x80\x8b\n11:59:03 PM:   Error message\n11:59:03 PM:   Error: This site does not seem to be using Next.js. Please run "npm install next" in the repository.\n11:59:03 PM:   If you are using a monorepo, please see the docs on configuring your site: https://ntl.fyi/next-monorepos\n11:59:03 PM: \xe2\x80\x8b\n11:59:03 PM:   Plugin details\n11:59:03 PM:   Package:        @netlify/plugin-nextjs\n11:59:03 PM:   Version:        3.9.2\n11:59:03 PM:   Repository:     git+https://github.com/netlify/netlify-plugin-nextjs.git\n11:59:03 PM:   npm link:       https://www.npmjs.com/package/@netlify/plugin-nextjs\n11:59:03 PM:   Report issues:  https://github.com/netlify/netlify-plugin-nextjs/issues\n11:59:03 PM: \xe2\x80\x8b\n11:59:03 PM:   Error location\n11:59:03 PM:   In "onPreBuild" event in "@netlify/plugin-nextjs" from netlify.toml\n11:59:03 PM:       at validateNextUsage (/.netlify/plugins/node_modules/@netlify/plugin-nextjs/helpers/validateNextUsage.js:15:12)\n11:59:03 PM:       at onPreBuild (/.netlify/plugins/node_modules/@netlify/plugin-nextjs/index.js:32:5)\n11:59:03 PM: \xe2\x80\x8b\n11:59:03 PM:   Resolved config\n11:59:03 PM:   build:\n11:59:03 PM:     command: next build\n11:59:03 PM:     commandOrigin: config\n11:59:03 PM:     environment:\n11:59:03 PM:       - FACEBOOK_APP_ID\n11:59:03 PM:       - FACEBOOK_APP_SECRET\n11:59:03 PM:       - GATSBY_STRIPE_PK\n11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_API_KEY\n11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_APPID\n11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN\n11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_DATABASE_URL\n11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID\n11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_PROJECT_ID\n11:59:03 PM:       - NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET\n11:59:03 PM:       - NEXT_PUBLIC_STRAPI\n11:59:03 PM:       - NEXT_PUBLIC_STRAPI_DEV\n11:59:03 PM:       - NEXT_PUBLIC_STRAPI_FETCH\n11:59:03 PM:       - NEXT_PUBLIC_STRAPI_PROD\n11:59:03 PM:       - STRAPI_API\n11:59:03 PM:       - CYPRESS_CACHE_FOLDER\n11:59:03 PM:     ignore: git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../\n11:59:03 PM:     publish: /opt/build/repo/.next\n11:59:03 PM:     publishOrigin: config\n11:59:03 PM:   plugins:\n11:59:03 PM:     - inputs: {}\n11:59:03 PM:       origin: config\n11:59:03 PM:       package: \'@netlify/plugin-nextjs\'\n11:59:04 PM: Caching artifacts\n11:59:04 PM: Started saving node modules\n11:59:04 PM: Finished saving node modules\n11:59:04 PM: Started saving build plugins\n11:59:04 PM: Finished saving build plugins\n11:59:04 PM: Started saving yarn cache\n11:59:29 PM: Finished saving yarn cache\n11:59:29 PM: Started saving pip cache\n11:59:29 PM: Finished saving pip cache\n11:59:29 PM: Started saving emacs cask dependencies\n11:59:29 PM: Finished saving emacs cask dependencies\n
Run Code Online (Sandbox Code Playgroud)\n

这是我的 package.json 文件:

\n
{\n  "name": "@minimal/minimal-kit-react",\n  "author": "minimals.cc",\n  "version": "2.6.0",\n  "private": true,\n  "scripts": {\n    "dev": "next dev -p 3222",\n    "build": "next build",\n    "start": "next start"\n  },\n  "dependencies": {\n    "@apollo/client": "^3.4.16",\n    "@auth0/auth0-spa-js": "1.18",\n    "@emotion/cache": "^11.4.0",\n    "@emotion/react": "^11.4.1",\n    "@emotion/server": "^11.4.0",\n    "@emotion/styled": "^11.3.0",\n    "@fontsource/alata": "^4.5.0",\n    "@fontsource/barlow": "^4.5.0",\n    "@fontsource/inter": "^4.5.0",\n    "@fontsource/karla": "^4.5.0",\n    "@fontsource/poppins": "^4.5.0",\n    "@fontsource/public-sans": "^4.5.0",\n    "@fontsource/raleway": "^4.5.0",\n    "@fullcalendar/daygrid": "^5.9.0",\n    "@fullcalendar/interaction": "^5.9.0",\n    "@fullcalendar/list": "^5.9.0",\n    "@fullcalendar/react": "^5.9.0",\n    "@fullcalendar/timegrid": "^5.9.0",\n    "@fullcalendar/timeline": "^5.9.0",\n    "@hookform/devtools": "^4.0.1",\n    "@hookform/resolvers": "^2.8.0",\n    "@iconify/icons-ant-design": "^1.1.0",\n    "@iconify/icons-eva": "^1.1.0",\n    "@iconify/icons-ic": "^1.1.10",\n    "@iconify/icons-simple-icons": "^1.1.46",\n    "@material-ui/core": "^4.11.0",\n    "@material-ui/data-grid": "^4.0.0-alpha.21",\n    "@material-ui/icons": "^4.11.2",\n    "@material-ui/lab": "^4.0.0-alpha.56",\n    "@mui/icons-material": "^5.0.0",\n    "@mui/lab": "^5.0.0-alpha.47",\n    "@mui/material": "^5.0.0",\n    "@mui/styles": "^5.0.0",\n    "@mui/utils": "^5.0.0",\n    "@mui/x-data-grid": "^5.0.0-beta.1",\n    "@react-pdf/renderer": "^2.0.19",\n    "@reduxjs/toolkit": "^1.6.1",\n    "@stripe/react-stripe-js": "^1.5.0",\n    "@stripe/stripe-js": "^1.18.0",\n    "@testing-library/jest-dom": "^5.14.1",\n    "@testing-library/react": "^12.1.0",\n    "@testing-library/user-event": "^13.2.1",\n    "@turf/bbox": "^6.5.0",\n    "amazon-cognito-identity-js": "^5.1.0",\n    "animejs": "^3.2.1",\n    "apexcharts": "^3.28.3",\n    "autosuggest-highlight": "^3.1.1",\n    "axios": "^0.21.4",\n    "axios-mock-adapter": "^1.20.0",\n    "change-case": "^4.1.2",\n    "d3-array": "^3.0.2",\n    "d3-scale": "^4.0.0",\n    "date-fns": "^2.24.0",\n    "deck.gl": "^8.5.8",\n    "dotenv": "^10.0.0",\n    "draft-js": "^0.11.7",\n    "draftjs-to-html": "^0.9.1",\n    "emoji-mart": "^3.0.0",\n    "firebase": "^8.10.0",\n    "formik": "^2.2.9",\n    "framer-motion": "^4.1.17",\n    "fs": "^0.0.1-security",\n    "graphql": "^15.7.1",\n    "highlight.js": "^11.3.1",\n    "history": "^5.0.1",\n    "i18next": "^20.6.1",\n    "i18next-browser-languagedetector": "^6.1.2",\n    "immutable": "^4.0.0-rc.14",\n    "jsonwebtoken": "^8.5.1",\n    "jwt-decode": "^3.1.2",\n    "lazysizes": "^5.3.2",\n    "lodash": "^4.17.21",\n    "lowlight": "^2.4.0",\n    "madge": "^5.0.1",\n    "mapbox-gl": "^2.4.1",\n    "next": "^11.1.2",\n    "notistack": "^1.0.6-next.3",\n    "nprogress": "^0.2.0",\n    "numeral": "^2.0.6",\n    "pnp-webpack-plugin": "^1.7.0",\n    "process": "^0.11.10",\n    "prop-types": "^15.7.2",\n    "react": "17.0.2",\n    "react-apexcharts": "^1.3.9",\n    "react-beautiful-dnd": "^13.1.0",\n    "react-copy-to-clipboard": "^5.0.4",\n    "react-dom": "17.0.2",\n    "react-draft-wysiwyg": "^1.14.7",\n    "react-dropzone": "^11.4.0",\n    "react-helmet-async": "^1.1.2",\n    "react-highlight": "^0.14.0",\n    "react-hook-form": "^7.15.3",\n    "react-i18next": "^11.12.0",\n    "react-image-lightbox": "^5.1.4",\n    "react-infinite-scroll-component": "^6.1.0",\n    "react-intersection-observer": "^8.32.1",\n    "react-lottie": "^1.2.3",\n    "react-map-gl": "^6.1.17",\n    "react-markdown": "^7.1.0",\n    "react-quill": "^2.0.0-beta.4",\n    "react-redux": "^7.2.5",\n    "react-resize-aware": "^3.1.1",\n    "react-scripts": "^4.0.1",\n    "react-scroll": "^1.8.4",\n    "react-slick": "^0.28.0",\n    "react-spring": "^9.2.4",\n    "redux": "^4.1.1",\n    "redux-persist": "^6.0.0",\n    "rehype-highlight": "^5.0.0",\n    "rehype-raw": "^6.1.0",\n    "simplebar": "^5.3.5",\n    "simplebar-react": "^2.3.5",\n    "slick-carousel": "^1.8.1",\n    "stylis": "^4.0.10",\n    "stylis-plugin-rtl": "^2.0.2",\n    "typescript": "^4.3.5",\n    "uuid": "^8.3.2",\n    "worker-loader": "^3.0.8",\n    "yup": "^0.32.9"\n  },\n  "devDependencies": {\n    "@babel/core": "^7.15.8",\n    "@babel/eslint-parser": "^7.15.4",\n    "@babel/preset-react": "^7.14.5",\n    "@iconify/icons-fa-solid": "^1.1.1",\n    "@iconify/react": "^3.0.1",\n    "@netlify/plugin-nextjs": "^4.0.0-beta.5",\n    "@types/node": "^16.7.13",\n    "@typescript-eslint/eslint-plugin": "^4.31.0",\n    "@typescript-eslint/parser": "^4.31.0",\n    "eslint": "^7.32.0",\n    "eslint-config-airbnb": "^18.2.1",\n    "eslint-config-airbnb-typescript": "^14.0.0",\n    "eslint-config-prettier": "^8.3.0",\n    "eslint-config-wesbos": "2.1.0",\n    "eslint-plugin-html": "^6.1.2",\n    "eslint-plugin-import": "^2.24.2",\n    "eslint-plugin-jsx-a11y": "^6.4.1",\n    "eslint-plugin-prettier": "^4.0.0",\n    "eslint-plugin-react": "^7.25.1",\n    "eslint-plugin-react-hooks": "^4.2.0",\n    "graphql": "latest",\n    "prettier": "^2.3.2",\n    "typescript": "^4.4.2"\n  }\n}\n\n
Run Code Online (Sandbox Code Playgroud)\n

这是我的 netlify.toml:

\n
[build]\npublish = ".next"\n\n[[plugins]]\npackage = "@netlify/plugin-nextjs"\n\n
Run Code Online (Sandbox Code Playgroud)\n

gbe*_*ade 7

我也有同样的问题。从 Netlify 的插件选项卡中删除 @netlify/plugin-nextjs 解决了我的问题。我删除了插件并触发了新的部署。