typescript NextJS -致命错误:无效的标记压缩接近堆限制分配失败- JavaScript堆内存不足

yeotifhr  于 2023-02-20  发布在  TypeScript
关注(0)|答案(2)|浏览(155)

我有NextJS的typescript应用程序,与30页和一些依赖关系。我试图建立它的自由示例有512 MB的内存,但有时甚至不能完成构建检查类型的有效性的步骤。我得到错误致命错误:无效的标记压缩接近堆限制分配失败- JavaScript堆内存不足
这里是package.json

{
      "name": "app",
      "scripts": {
        "dev": "next dev",
        "build": "NODE_OPTIONS=\" --max-old-space-size=512\"  next build",
        "prestart": "npm run build",
        "start": "NODE_OPTIONS=\"--max-old-space-size=512\" next start","test": "start-server-and-test dev 3000 cypress:open",
        "type:check": "yarn tsc --project tsconfig.json --pretty --noEmit",
        "prepare": "husky install"
      },
      "dependencies": {
        "@fortawesome/fontawesome-svg-core": "^1.3.0",
        "@fortawesome/free-regular-svg-icons": "^6.0.0",
        "@fortawesome/free-solid-svg-icons": "^6.0.0",
        "@fortawesome/react-fontawesome": "^0.1.17",
        "@lexical/react": "^0.7.1",
        "@reduxjs/toolkit": "^1.7.2",
        "@tangdw/react-viewer": "^3.2.7",
        "antd": "^4.18.8",
        "antd-dayjs-webpack-plugin": "^1.0.6",
        "autoprefixer": "^10.4.7",
        "bootstrap": "5.1.3",
        "country-list": "^2.2.0",
        "draft-js": "^0.11.7",
        "draftjs-to-html": "^0.9.1",
        "formik": "^2.2.9",
        "formik-antd": "^2.0.4",
        "html-to-draftjs": "^1.5.0",
        "jsonwebtoken": "^8.5.1",
        "jwt-decode": "^3.1.2",
        "lodash": "^4.17.21",
        "moment": "^2.29.1",
        "next": "12.0.10",
        "next-pwa": "^5.6.0",
        "nprogress": "^0.2.0",
        "postcss": "^8.4.14",
        "query-string": "^7.1.1",
        "react": "17.0.2",
        "react-dom": "17.0.2",
        "react-draft-wysiwyg": "^1.15.0",
        "react-feather": "^2.0.10",
        "react-icons": "^4.3.1",
        "react-multi-carousel": "^2.8.0",
        "react-redux": "^7.2.6",
        "react-share": "^4.4.1",
        "react-show-more-text": "^1.5.2",
        "react-slick": "^0.29.0",
        "react-typical": "^0.1.3",
        "react-viewer": "^3.2.2",
        "tailwindcss": "^3.0.24",
        "yup": "^0.32.11"
      },
      "devDependencies": {
        "@types/node": "17.0.15",
        "@types/react": "17.0.39",
        "@types/react-show-more-text": "^1.4.2",
        "@typescript-eslint/eslint-plugin": "^5.11.0",
        "@typescript-eslint/parser": "^5.11.0",
        "@types/jsonwebtoken": "^8.5.8",
        "@types/nprogress": "^0.2.0",
        "@types/react-typical": "^0.1.0",
        "cypress": "^9.5.1",
        "eslint": "8.8.0",
        "eslint-config-next": "12.0.10",
        "eslint-config-prettier": "^8.3.0",
        "eslint-plugin-jsx-a11y": "^6.5.1",
        "eslint-plugin-prettier": "^4.0.0",
        "eslint-plugin-react": "^7.28.0",
        "eslint-plugin-react-hooks": "^4.3.0",
        "husky": ">=6",
        "lint-staged": ">=10",
        "miragejs": "^0.1.43",
        "prettier": "2.5.1",
        "start-server-and-test": "^1.14.0",
        "typescript": "4.5.5"
      },
    }

有办法解决吗?

ndh0cuux

ndh0cuux1#

另一个选项是在本地生成,然后手动将生成文件上载到服务器。
我以前在我的服务器上做这个。

0kjbasz6

0kjbasz62#

看起来只是内存不足。最近我在用8GB内存构建VPS时遇到了内存问题。但是有几个项目。所以我可以建议购买一个更强大的示例。
512 MB可能不够30页。

相关问题