使用 vercel 部署 React 项目时出错

时间:2021-04-22 20:42:53

标签: reactjs github vercel

我正在学习使用 github 和 vercel。在部署使用 CRA vercel 创建的 React 项目时,似乎总是抛出错误并且部署失败。我尝试寻找解决此问题的方法,例如将环境变量设置为 CI = falsenpm install date-fns --save 等等,但它仍然显示错误 这是错误日志

02:00:48    Analyzing source code...
02:00:50    Installing build runtime...
02:00:53    Build runtime installed: 3.090s
02:00:56    Looking up build cache...
02:00:57    Build cache not found
02:00:58    Detected package.json
02:00:58    Installing dependencies...
02:01:31    > core-js@2.6.12 postinstall /vercel/path0/node_modules/babel-runtime/node_modules/core-js
02:01:31    > node -e "try{require('./postinstall')}catch(e){}"
02:01:31    > core-js@3.10.2 postinstall /vercel/path0/node_modules/core-js
02:01:31    > node -e "try{require('./postinstall')}catch(e){}"
02:01:31    > core-js-pure@3.10.2 postinstall /vercel/path0/node_modules/core-js-pure
02:01:31    > node -e "try{require('./postinstall')}catch(e){}"
02:01:31    > ejs@2.7.4 postinstall /vercel/path0/node_modules/ejs
02:01:31    > node ./postinstall.js
02:01:34    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
02:01:34    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
02:01:34    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
02:01:34    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
02:01:34    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
02:01:34    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
02:01:34    added 1950 packages from 767 contributors in 34.685s
02:01:35    136 packages are looking for funding
02:01:35      run `npm fund` for details
02:01:35    Running "npm run build"
02:01:36    > movie-search-app@0.1.0 build /vercel/path0
02:01:36    > react-scripts build
02:01:37    Creating an optimized production build...
02:01:45    Failed to compile.
02:01:45    Error: html-webpack-plugin could not minify the generated output.
02:01:45      In production mode the html minifcation is enabled by default.
02:01:45      If you are not generating a valid html output please disable it manually.
02:01:45      You can do so by adding the following setting to your HtmlWebpackPlugin config  :
02:01:45      |
02:01:45      |    minify: false
02:01:45      |
02:01:45      See https://github.com/jantimon/html-webpack-plugin#options for details.
02:01:45      For parser dedicated bugs please create an issue here:
02:01:45      https://danielruf.github.io/html-minifier-terser/
02:01:45      Parse Error: <link rel="stylesheet" href="styles.css"
02:01:45        </head>
02:01:45        <body>
02:01:45          <noscript>You need to enable JavaScript to run this app.</noscript>
02:01:45          <div id="root"></div>
02:01:45          <!--
02:01:45            This HTML file is a template.
02:01:45            If you open it directly in the browser, you will see an empty page.
02:01:45            You can add webfonts, meta tags, or analytics to this file.
02:01:45            The build step will place the bundled scripts into the <body> tag.
02:01:45            To begin the development, run `npm start` or `yarn start`.
02:01:45            To create a production bundle, use `npm run build` or `yarn build`.
02:01:45          -->
02:01:45        <script>!function(e){function r(r){for(var n,a,p=r[0],i=r[1],l=r[2],c=0,s=[]  ;c<p.length;c++)a=p[c],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push  (o[a][0]),o[a]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i  [n]);for(f&&f(r);s.length;)s.shift()();return u.push.apply(u,l||[]),t()}functi  on t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,p=1;p<t.length;p++){v  ar i=t[p];0!==o[i]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={  },o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,  exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=e,a  .c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,ge  t:t})},a.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object  .defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e  ,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(  4&r&&"object"===typeof e&&e&&e.__esModule)return e;var t=Object.create(null);i  f(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"stri  ng"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));re  turn t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:fun  ction(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.proto  type.hasOwnProperty.call(e,r)},a.p="/";var p=this["webpackJsonpmovie-search-ap  p"]=this["webpackJsonpmovie-search-app"]||[],i=p.push.bind(p);p.push=r,p=p.sli  ce();for(var l=0;l<p.length;l++)r(p[l]);var f=i;t()}([]);
02:01:45      //# sourceMappingURL=runtime-main.cbd60e9b.js.map</script><script src="/static  /js/2.a0c9e90c.chunk.js"></script><script src="/static/js/main.fac56600.chunk.  js"></script></body>
02:01:45      </html>
02:01:45      
02:01:45      - htmlparser.js:244 new HTMLParser
02:01:45        [path0]/[html-minifier-terser]/src/htmlparser.js:244:13
02:01:45      
02:01:45      - htmlminifier.js:993 minify
02:01:45        [path0]/[html-minifier-terser]/src/htmlminifier.js:993:3
02:01:45      
02:01:45      - htmlminifier.js:1354 Object.exports.minify
02:01:45        [path0]/[html-minifier-terser]/src/htmlminifier.js:1354:16
02:01:45      
02:01:45      - index.js:1013 HtmlWebpackPlugin.minifyHtml
02:01:45        [path0]/[html-webpack-plugin]/index.js:1013:46
02:01:45      
02:01:45      - index.js:429 HtmlWebpackPlugin.postProcessHtml
02:01:45        [path0]/[html-webpack-plugin]/index.js:429:40
02:01:45      
02:01:45      - index.js:254 
02:01:45        [path0]/[html-webpack-plugin]/index.js:254:25
02:01:45      
02:01:45      - task_queues.js:93 processTicksAndRejections
02:01:45        internal/process/task_queues.js:93:5
02:01:45    npm ERR! code ELIFECYCLE
02:01:45    npm ERR! errno 1
02:01:45    npm ERR! movie-search-app@0.1.0 build: `react-scripts build`
02:01:45    npm ERR! Exit status 1
02:01:45    npm ERR! 
02:01:45    npm ERR! Failed at the movie-search-app@0.1.0 build script.
02:01:45    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
02:01:45    npm ERR! A complete log of this run can be found in:
02:01:45    npm ERR!     /vercel/.npm/_logs/2021-04-22T20_31_45_116Z-debug.log
02:01:45    Error: Command "npm run build" exited with 1

这是我的 package.json

{
  "name": "movie-search-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.10",
    "@testing-library/react": "^11.2.6",
    "@testing-library/user-event": "^12.8.3",
    "date-fns": "^2.21.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.1.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

0 个答案:

没有答案