首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行npm运行生成时的错误代码ELIFECYCLE

运行npm运行生成时的错误代码ELIFECYCLE
EN

Stack Overflow用户
提问于 2022-01-14 14:12:27
回答 1查看 1K关注 0票数 3

我已经构建了基于fuse react主题的react应用程序-- npm start在开发环境中运行的很好,但是我在进行生产构建时遇到了错误,运行npm run build来生成产品,但是得到了ELIFECYCLE错误,我尝试了所有的选项,比如。

代码语言:javascript
复制
npm ERR! code ELIFECYCLE 
npm ERR! errno 1
npm ERR! fuse-react-app@6.1.4 build: `cross-env 
GENERATE_SOURCEMAP=false craco build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the fuse-react-app@6.1.4 build script.
npm ERR! This is probably not a problem with npm. There is likely 
additional logging output above.

package-lock.json

  • Delete node_modules

  • Ran npm install

  • Ran
  1. Remove npm start和app运行良好,我可以访问浏览器上的应用程序
  2. Ran npm run build获取ELIFECYCLE错误

这是我的package.json文件

代码语言:javascript
复制
{
"name": "fuse-react-app",
"version": "6.1.4",
"private": true,
"dependencies": {
    "@date-io/core": "1.3.13",
    "@date-io/date-fns": "1.3.13",
    "@date-io/moment": "1.3.13",
    "@fullcalendar/core": "5.7.0",
    "@fullcalendar/daygrid": "5.7.0",
    "@fullcalendar/interaction": "5.7.0",
    "@fullcalendar/react": "5.7.0",
    "@fullcalendar/timegrid": "5.7.0",
    "@hookform/resolvers": "2.5.1",
    "@material-ui/core": "4.11.4",
    "@material-ui/data-grid": "latest",
    "@material-ui/icons": "4.11.2",
    "@material-ui/lab": "4.0.0-alpha.58",
    "@material-ui/pickers": "3.3.10",
    "@mui/material": "^5.2.4",
    "@mui/x-data-grid-pro": "^4.0.0",
    "@reduxjs/toolkit": "1.5.1",
    "apexcharts": "3.26.3",
    "auth0-lock": "11.30.0",
    "autosuggest-highlight": "3.1.1",
    "axios": "0.21.1",
    "axios-mock-adapter": "1.19.0",
    "chart.js": "2.9.4",
    "clsx": "1.1.1",
    "cross-fetch": "3.1.4",
    "date-fns": "2.21.3",
    "draft-js": "0.11.7",
    "draftjs-to-html": "0.9.1",
    "firebase": "8.6.2",
    "formsy-react": "2.2.5",
    "framer-motion": "4.1.17",
    "google-map-react": "2.1.9",
    "history": "4.10.1",
    "i18next": "20.3.0",
    "jsonwebtoken": "8.5.1",
    "jss": "10.6.0",
    "jss-plugin-extend": "10.6.0",
    "jss-rtl": "0.3.0",
    "jwt-decode": "2.2.0",
    "keycode": "2.2.0",
    "lodash": "4.17.21",
    "marked": "0.8.2",
    "material-table": "^1.69.3",
    "material-ui-dropzone": "^3.5.0",
    "material-ui-popup-state": "1.8.3",
    "millify": "^4.0.0",
    "mobile-detect": "1.4.5",
    "moment": "^2.29.1",
    "notistack": "1.0.9",
    "path-to-regexp": "3.2.0",
    "perfect-scrollbar": "1.5.1",
    "prismjs": "1.23.0",
    "prop-types": "15.7.2",
    "qs": "6.10.1",
    "raw-loader": "4.0.2",
    "react": "17.0.2",
    "react-apexcharts": "1.3.9",
    "react-autosuggest": "10.1.0",
    "react-beautiful-dnd": "13.1.0",
    "react-chartjs-2": "2.11.2",
    "react-compound-timer": "^1.2.0",
    "react-dom": "17.0.2",
    "react-draft-wysiwyg": "1.14.7",
    "react-draggable": "4.4.3",
    "react-frame-component": "4.1.3",
    "react-hook-form": "7.7.1",
    "react-i18next": "11.9.0",
    "react-iframe": "^1.8.0",
    "react-json-editor-ajrm": "^2.5.13",
    "react-json-view": "^1.21.3",
    "react-masonry-css": "1.0.16",
    "react-number-format": "4.5.5",
    "react-popper": "1.3.11",
    "react-redux": "7.2.4",
    "react-router": "5.2.0",
    "react-router-config": "5.1.1",
    "react-router-dom": "5.2.0",
    "react-scripts": "^4.0.3",
    "react-select": "3.2.0",
    "react-show-more-text": "^1.5.0",
    "react-sparklines": "^1.7.0",
    "react-spring": "9.1.2",
    "react-swipeable": "6.1.2",
    "react-swipeable-views": "0.13.9",
    "react-swipeable-views-utils": "0.13.9",
    "react-table": "7.7.0",
    "react-terminal-component": "^1.5.0",
    "react-text-mask": "5.4.3",
    "react-virtualized": "9.22.3",
    "react-window": "1.8.6",
    "redux": "4.1.0",
    "redux-logger": "4.0.0",
    "styled-components": "5.3.0",
    "typeface-poppins": "1.1.13",
    "velocity-animate": "1.5.2",
    "velocity-react": "1.4.3",
    "web-vitals": "^0.2.4",
    "yup": "0.32.9"
},
"peerDependencies": {
    "autoprefixer": "9.8.6",
    "postcss": "7.0.35",
    "react": "17.0.2",
    "react-dom": "17.0.2"
},
"resolutions": {
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "babel-loader": "8.1.0"
},
"devDependencies": {
    "@babel/core": "7.12.17",
    "@babel/node": "7.12.17",
    "@babel/plugin-transform-react-jsx": "7.12.17",
    "@babel/preset-env": "7.12.17",
    "@craco/craco": "^6.1.2",
    "@tailwindcss/postcss7-compat": "2.1.2",
    "@typescript-eslint/eslint-plugin": "^4.25.0",
    "@typescript-eslint/parser": "^4.25.0",
    "@yarnpkg/pnpify": "2.4.0",
    "autoprefixer": "9.8.6",
    "babel-eslint": "10.1.0",
    "cross-env": "7.0.3",
    "eslint": "7.27.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-config-prettier": "^8.3.0",
    "eslint-config-react-app": "^6.0.0",
    "eslint-import-resolver-node": "^0.3.4",
    "eslint-plugin-flowtype": "^5.7.2",
    "eslint-plugin-import": "^2.23.3",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-prettier": "^3.4.0",
    "eslint-plugin-react": "^7.23.2",
    "eslint-plugin-react-hooks": "^4.2.0",
    "js-beautify": "1.13.13",
    "postcss": "7.0.35",
    "prettier": "^2.3.0",
    "promise": "8.1.0",
    "source-map-explorer": "2.5.2",
    "tailwindcss": "npm:@tailwindcss/postcss7-compat@2.1.2",
    "tailwindcss-dir": "4.0.0"
},
"scripts": {
    "start": "craco start",
    "build": "cross-env GENERATE_SOURCEMAP=false craco build",
    "test": "craco test --env=node",
    "eject": "craco eject",
    "build-docs": "find ./src/app/main/documentation/material-ui-components \\( -name '*.ts' -o -name '*.tsx' \\) -type f -delete && babel-node --presets @babel/preset-env src/app/main/documentation/material-ui-components/build.js",
    "analyze": "craco build && source-map-explorer 'build/static/js/*.js' --html analyze-result.html",
    "pnpify-sdk": "yarn pnpify --sdk",
    "lint": "eslint"
},
"browserslist": {
    "production": [
        ">0.2%",
        "not dead",
        "not op_mini all"
    ],
    "development": [
        "last 1 chrome version",
        "last 1 firefox version",
        "last 3 safari version"
    ]
}}

节点版本= 14.2.0

npm版本= 6.14.4

任何解决方案,如何解决上述错误,并进行生产建设。

EN

回答 1

Stack Overflow用户

发布于 2022-01-23 07:42:23

我认为主要原因是使用了cross-env包。否则,其他脚本也会导致同样的错误。

FOr测试目的,删除cross-env GENERATE_SOURCEMAP=false并手动传递false而不是process.env.GENERATE_SOURCEMAP。所以您的build脚本应该是

代码语言:javascript
复制
 "build": "craco build",

如果

  • 不能工作,则清除缓存。

npm缓存干净的-force

删除.npm

代码语言:javascript
复制
 rm -rf ~/.npm

然后删除lock.json和node_modules,然后重新安装

代码语言:javascript
复制
  npm install
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70711905

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档