Umi: 服务器 build 失败

Created on 25 Jun 2019  ·  9Comments  ·  Source: umijs/umi

ERROR  Failed to compile with 1 errors4:01:11 PM

 error  in ./src/pages/.umi-production/umi.js

Module build failed (from ./node_modules/af-webpack/node_modules/babel-loader/lib/index.js):
Error: [BABEL] /home/gitlab-runner/builds/d7d91198/0/tongyu-fe/BCT/src/pages/.umi-production/umi.js: Invalid Option: corejs is not a valid top-level option.
        Maybe you meant to use 'targets'? (While processing: "/home/gitlab-runner/builds/d7d91198/0/tongyu-fe/BCT/node_modules/babel-preset-umi/node_modules/@babel/preset-env/lib/index.js")
    at validateTopLevelOptions (/home/gitlab-runner/builds/d7d91198/0/tongyu-fe/BCT/node_modules/babel-preset-umi/node_modules/@babel/preset-env/lib/normalize-options.js:49:13)
    at normalizeOptions (/home/gitlab-runner/builds/d7d91198/0/tongyu-fe/BCT/node_modules/babel-preset-umi/node_modules/@babel/preset-env/lib/normalize-options.js:160:3)
    at _default (/home/gitlab-runner/builds/d7d91198/0/tongyu-fe/BCT/node_modules/babel-preset-umi/node_modules/@babel/preset-env/lib/index.js:168:37)
    at /home/gitlab-runner/builds/d7d91198/0/tongyu-fe/BCT/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
    at loadDescriptor (/home/gitlab-runner/builds/d7d91198/0/tongyu-fe/BCT/node_modules/af-webpack/node_modules/babel-loader/node_modules/@babel/core/lib/config/full.js:165:14)
    at cachedFunction (/home/gitlab-runner/builds/d7d91198/0/tongyu-fe/BCT/node_modules/af-webpack/node_modules/babel-loader/node_modules/@babel/core/lib/config/caching.js:33:19)
    at loadPresetDescriptor (/home/gitlab-runner/builds/d7d91198/0/tongyu-fe/BCT/node_modules/af-webpack/node_modules/babel-loader/node_modules/@babel/core/lib/config/full.js:235:63)
    at config.presets.reduce (/home/gitlab-runner/builds/d7d91198/0/tongyu-fe/BCT/node_modules/af-webpack/node_modules/babel-loader/node_modules/@babel/core/lib/config/full.js:77:21)
    at Array.reduce (<anonymous>)
    at recurseDescriptors (/home/gitlab-runner/builds/d7d91198/0/tongyu-fe/BCT/node_modules/af-webpack/node_modules/babel-loader/node_modules/@babel/core/lib/config/full.js:74:38)
    at recurseDescriptors (/home/gitlab-runner/builds/d7d91198/0/tongyu-fe/BCT/node_modules/af-webpack/node_modules/babel-loader/node_modules/@babel/core/lib/config/full.js:94:27)
    at loadFullConfig (/home/gitlab-runner/builds/d7d91198/0/tongyu-fe/BCT/node_modules/af-webpack/node_modules/babel-loader/node_modules/@babel/core/lib/config/full.js:108:6)
    at process.nextTick (/home/gitlab-runner/builds/d7d91198/0/tongyu-fe/BCT/node_modules/af-webpack/node_modules/babel-loader/node_modules/@babel/core/lib/transform.js:28:33)
    at process._tickCallback (internal/process/next_tick.js:61:11)

 @ multi ./src/pages/.umi-production/umi.js

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Most helpful comment

APP_ROOT=$PWD/app/web umi build

✖ Webpack
Compiled with some errors in 35.09s

ERROR Failed to compile with 1 errors 19:20:55

error in ./app/web/src/pages/.umi-production/router.js

Module parse failed: Unexpected token (33:13)
File was processed with these loaders:

  • ./node_modules/babel-loader/lib/index.js
    You may need an additional loader to handle the result of these loaders.
    | "component": __IS_BROWSER ? (0, _dynamic2.default)({
    | component: function component() {
  return import(

| /* webpackChunkName: "layouts__UserLayout" */
| '../../layouts/UserLayout');

@ ./app/web/src/pages/.umi-production/umi.js 94:57-76
@ multi ./node_modules/umi-build-dev/template/setPublicPath.js ./app/web/src/pages/.umi-production/umi.js

npm ERR! code ELIFECYCLE
npm ERR! errno 1

version : 2.8.3

All 9 comments

umi@^2.2.7:
  version "2.8.3"

APP_ROOT=$PWD/app/web umi build

✖ Webpack
Compiled with some errors in 35.09s

ERROR Failed to compile with 1 errors 19:20:55

error in ./app/web/src/pages/.umi-production/router.js

Module parse failed: Unexpected token (33:13)
File was processed with these loaders:

  • ./node_modules/babel-loader/lib/index.js
    You may need an additional loader to handle the result of these loaders.
    | "component": __IS_BROWSER ? (0, _dynamic2.default)({
    | component: function component() {
  return import(

| /* webpackChunkName: "layouts__UserLayout" */
| '../../layouts/UserLayout');

@ ./app/web/src/pages/.umi-production/umi.js 94:57-76
@ multi ./node_modules/umi-build-dev/template/setPublicPath.js ./app/web/src/pages/.umi-production/umi.js

npm ERR! code ELIFECYCLE
npm ERR! errno 1

version : 2.8.3

Module parse failed: Unexpected token (16:13)

File was processed with these loaders:

  • ./node_modules/babel-loader/lib/index.js

You may need an additional loader to handle the result of these loaders.

| "component": __IS_BROWSER ? _dvaDynamic({

| component: function component() {

return import('../../layouts/UserLayout');

| },

| LoadingComponent: require('/tmp/build/src/src/components/PageLoading/index').default

@ ./src/pages/.umi-production/umi.js 77:48-67

@ multi ./src/pages/.umi-production/umi.js

一样的错误,version:2.8.4

提供一个可复现的例子

以前都能构建成功,今天突然不行了,很奇怪。
image

本地构建可以成功。

Module parse failed: Unexpected token (16:13)

File was processed with these loaders:

  • ./node_modules/babel-loader/lib/index.js

You may need an additional loader to handle the result of these loaders.

| "component": __IS_BROWSER ? _dvaDynamic({

| component: function component() {

return import('../../layouts/UserLayout');

| },

| LoadingComponent: require('/tmp/build/src/src/components/PageLoading/index').default

@ ./src/pages/.umi-production/umi.js 77:48-67

@ multi ./src/pages/.umi-production/umi.js

一样的错误,version:2.8.4

@ycjcl868 可以帮忙看看不,项目上线不了,挺着急的,发了自己代码master也不可以

我解决了。
是npm的问题,换成yarn就可以了。

删除 package-lock.jsonyarn.lock ,重新安装依赖

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zemzheng picture zemzheng  ·  3Comments

y2891663091 picture y2891663091  ·  4Comments

nguyenhuutinh picture nguyenhuutinh  ·  3Comments

mizi-lin picture mizi-lin  ·  3Comments

tauruswang picture tauruswang  ·  3Comments