Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm run build fails on a brand new project #6523

Closed
anselmoshim opened this issue May 3, 2020 · 2 comments · Fixed by #6527
Closed

npm run build fails on a brand new project #6523

anselmoshim opened this issue May 3, 2020 · 2 comments · Fixed by #6527

Comments

@anselmoshim
Copy link

anselmoshim commented May 3, 2020

Hi, I am getting errors when building a brand new project from scratch. Happens on both javascript and typscript versions of Ant Design Pro v4. The build finishes successfully on Windows, but not on CentOS (linux). Anyone know how to fix this issue?

Steps to reproduce:

$ yarn create umi  # or npm create umi

# Choose ant-design-pro:
 Select the boilerplate type (Use arrow keys)
❯ ant-design-pro  - Create project with an layout-only ant-design-pro boilerplate, use together with umi block.
  app             - Create project with a simple boilerplate, support typescript.
  block           - Create a umi block.
  library         - Create a library with umi.
  plugin          - Create a umi plugin.

$ git init
$ npm install
$ npm run build -> errors when running this
-bash-4.2$ npm run build

> ant-design-pro@1.0.0 build node_modules/myapp-ts
> umi build


✖ Webpack
  Compiled with some errors in 29.67s

 ERROR  Failed to compile with 2 errors                                                                          7:41:04 PM

 error  in ./src/global.less

Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
Error: Didn't get a result from child compiler
    at node_modules/myapp-ts/node_modules/mini-css-extract-plugin/dist/loader.js:144:23
    at node_modules/myapp-ts/node_modules/webpack/lib/Compiler.js:343:11
    at node_modules/myapp-ts/node_modules/webpack/lib/Compiler.js:681:15
    at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/myapp-ts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:22:1)
    at AsyncSeriesHook.lazyCompileHook (node_modules/myapp-ts/node_modules/tapable/lib/Hook.js:154:20)
    at node_modules/myapp-ts/node_modules/webpack/lib/Compiler.js:678:31
    at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/myapp-ts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at AsyncSeriesHook.lazyCompileHook (node_modules/myapp-ts/node_modules/tapable/lib/Hook.js:154:20)
    at node_modules/myapp-ts/node_modules/webpack/lib/Compilation.js:1423:35
    at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/myapp-ts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at AsyncSeriesHook.lazyCompileHook (node_modules/myapp-ts/node_modules/tapable/lib/Hook.js:154:20)
    at node_modules/myapp-ts/node_modules/webpack/lib/Compilation.js:1414:32
    at eval (eval at create (node_modules/myapp-ts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at node_modules/myapp-ts/node_modules/uglifyjs-webpack-plugin/dist/index.js:287:11
    at Runner.runTasks (node_modules/myapp-ts/node_modules/uglifyjs-webpack-plugin/dist/uglify/Runner.js:67:9)
    at UglifyJsPlugin.optimizeFn (node_modules/myapp-ts/node_modules/uglifyjs-webpack-plugin/dist/index.js:198:16)
    at node_modules/myapp-ts/node_modules/webpack/lib/NormalModule.js:316:20
    at node_modules/myapp-ts/node_modules/loader-runner/lib/LoaderRunner.js:367:11
    at node_modules/myapp-ts/node_modules/loader-runner/lib/LoaderRunner.js:182:20
    at context.callback (node_modules/myapp-ts/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at node_modules/myapp-ts/node_modules/mini-css-extract-plugin/dist/loader.js:144:14
    at node_modules/myapp-ts/node_modules/webpack/lib/Compiler.js:343:11
    at node_modules/myapp-ts/node_modules/webpack/lib/Compiler.js:681:15
    at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/myapp-ts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:22:1)
    at AsyncSeriesHook.lazyCompileHook (node_modules/myapp-ts/node_modules/tapable/lib/Hook.js:154:20)
    at node_modules/myapp-ts/node_modules/webpack/lib/Compiler.js:678:31
    at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/myapp-ts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at AsyncSeriesHook.lazyCompileHook (node_modules/myapp-ts/node_modules/tapable/lib/Hook.js:154:20)
    at node_modules/myapp-ts/node_modules/webpack/lib/Compilation.js:1423:35
    at AsyncSeriesHook.eval [as callAsync] (eval at create (node_modules/myapp-ts/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
    at AsyncSeriesHook.lazyCompileHook (node_modules/myapp-ts/node_modules/tapable/lib/Hook.js:154:20)
    at node_modules/myapp-ts/node_modules/webpack/lib/Compilation.js:1414:32

 @ ./src/pages/.umi-production/umi.js 219:0-28
 @ multi ./src/pages/.umi-production/umi.js

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

Module parse failed: Unexpected token (208:6)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     const props = this.props || {};
|     return (
>       <RendererWrapper0>
|         <Router history={history}>{renderRoutes(routes, props)}</Router>
|       </RendererWrapper0>

 @ ./src/pages/.umi-production/umi.js 66:38-57
 @ multi ./src/pages/.umi-production/umi.js

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ant-design-pro@1.0.0 build: `umi build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ant-design-pro@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     .npm/_logs/2020-05-03T23_41_04_974Z-debug.log

Works on Windows 10
Fails on CentOS

node version 12.16.3
umi version 2.13.0
antd version 4.0.0-rc1

@anselmoshim
Copy link
Author

anselmoshim commented May 4, 2020

Seems like similar issue here: umijs/umi#1623

       <RendererWrapper0>
         <Router history={history}>{renderRoutes(routes, props)}</Router>
       </RendererWrapper0>

exists in umi-production.js/router.js

It looks like the issue for me was that npm create umi was not using the latest Ant Design Pro build, so using yarn create umi fixed that.

However now I get this error when trying to run npm install

-bash-4.2$ npm install
npm WARN deprecated fsevents@1.2.12: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.

> ant-design-pro@1.0.0 postinstall /node_modules/test-2
> umi g tmp

Cannot use import statement outside a module
/node_modules/test-2/config/config.js:2
import { defineConfig } from 'umi';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1047:16)
    at Module._compile (internal/modules/cjs/loader.js:1097:27)
    at Module._compile (/node_modules/test-2/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Object.newLoader [as .js] (/node_modules/test-2/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at /node_modules/test-2/node_modules/@umijs/core/lib/Config/Config.js:218:69
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ant-design-pro@1.0.0 postinstall: `umi g tmp`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ant-design-pro@1.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /.npm/_logs/2020-05-04T08_13_34_974Z-debug.log

Running with --experimental-modules does not fix this issue.

@anselmoshim
Copy link
Author

fix for error is TypeStrong/ts-node#922 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant