NodeJS 在高端机器上创建react应用程序生产构建非常缓慢

u5rb5r59  于 2023-03-29  发布在  Node.js
关注(0)|答案(1)|浏览(96)

我们在产品构建的性能上遇到了一些问题。它需要大约20分钟的时间来构建。我们认为这可能是我们的机器,所以我们在一个32核和128 gb内存的服务器上运行它。
构建仍然花了大约20分钟,CPU使用率仅达到20%,内存达到2GB左右。
我已经包含了我们的package.json文件的副本以供参考;

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@syncfusion/ej2-react-buttons": "^17.4.51",
    "@syncfusion/ej2-react-calendars": "^17.4.51",
    "@syncfusion/ej2-react-charts": "^17.4.51",
    "@syncfusion/ej2-react-circulargauge": "^17.4.51",
    "@syncfusion/ej2-react-dropdowns": "^17.4.51",
    "@syncfusion/ej2-react-grids": "^17.4.55",
    "@syncfusion/ej2-react-inputs": "^17.4.55",
    "@syncfusion/ej2-react-navigations": "^18.1.52",
    "@syncfusion/ej2-react-pdfviewer": "^18.1.52",
    "@syncfusion/ej2-react-pivotview": "^18.1.52",
    "@syncfusion/ej2-react-popups": "^17.4.51",
    "@syncfusion/ej2-react-schedule": "^17.4.55",
    "@syncfusion/ej2-react-splitbuttons": "^17.4.55",
    "@types/react-mic": "^12.4.2",
    "axios": "^0.19.2",
    "bulma": "^0.8.2",
    "bulma-extensions": "^6.2.7",
    "cb-react-forms": "^1.1.0",
    "clientjs": "^0.1.11",
    "globalize": "^1.5.0",
    "js-cookie": "^2.2.1",
    "moment": "^2.26.0",
    "prettier": "^2.0.5",
    "react": "^16.13.1",
    "react-beforeunload": "^2.2.1",
    "react-data-table-component": "^3.10.3",
    "react-device-detect": "^1.12.1",
    "react-dom": "^16.13.1",
    "react-mic": "^12.4.6",
    "react-quiz-component": "^0.3.4",
    "react-router-dom": "^5.2.0",
    "sanitize-html": "^1.24.0",
    "videojs": "^1.0.0"
  },
  "scripts": {
    "dev": "cross-env  NODE_OPTIONS=--max_old_space_size=12192 react-scripts start",
    "build": "cross-env  NODE_OPTIONS=--max_old_space_size=12192  react-scripts build",
    "test": "cross-env CI=true react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@fortawesome/fontawesome-free": "^5.13.0",
    "@testing-library/react": "^8.0.4",
    "@types/ej.web.all": "^18.1.2",
    "@types/globalize": "^0.0.34",
    "@types/jest": "24.0.13",
    "@types/js-cookie": "^2.2.6",
    "@types/jsonwebtoken": "^8.5.0",
    "@types/node": "12.0.7",
    "@types/react": "16.8.19",
    "@types/react-big-calendar": "^0.22.4",
    "@types/react-dom": "16.8.4",
    "@types/react-pdf": "^4.0.5",
    "@types/react-router-dom": "^5.1.5",
    "@types/styled-components": "^4.4.3",
    "@types/styled-system": "^4.2.1",
    "cross-env": "^5.2.0",
    "gulp": "^4.0.2",
    "gzipper": "^3.7.0",
    "husky": "^3.1.0",
    "mockdate": "^2.0.5",
    "prettier": "^2.0.5",
    "react-app-rewired": "^2.1.6",
    "react-scripts": "^3.4.1",
    "react-testing-library": "^8.0.1",
    "styled-components": "^4.4.1",
    "styled-system": "^5.1.5",
    "typesafe-actions": "^4.4.2",
    "typescript": "^3.9.3",
    "yarn": "^1.22.4"
  },
  "husky": {
    "hooks": {
      "pre-push": "yarn test"
    }
  }
}

当运行dev/start时,大约需要一分钟的时间。有什么建议可以改善构建时间吗?

py49o6xq

py49o6xq1#

你试过yarn吗?根据我的经验,它比nom好

相关问题