easy-team / easywebpack-cli

A Powerful Cross-platform Webpack CLI Tool
https://easyjs.cn/easywebpack
MIT License
122 stars 28 forks source link

npm run build出错 #15

Closed lianfanghua closed 5 years ago

lianfanghua commented 5 years ago

环境:MacOS Mojave(版本 10.14.2)

$ npm ls -g -depth=0
/usr/local/lib
├── easywebpack-cli@4.3.3
├── npm@6.5.0
└── npm-check-updates@2.15.0

通过easy init初始化项目:

$ easy init
? please choose the boilerplate mode? Create Egg + Vue Server Side Render Application
? please choose the boilerplate project mode? Create Egg + Vue + TypeScript Application
? Please input project name: egg_vue_ssr_ts
? Please input project description:
? Please choose css style: stylus
? Please choose the way to install dependency: none
[easywebpack-cli]:query npm info of egg-vue-typescript-boilerplate
[easywebpack-cli]:downloading https://registry.npmjs.org/egg-vue-typescript-boilerplate/-/egg-vue-typescript-boilerplate-4.0.0
.tgz
[easywebpack-cli]:extract to /var/folders/v3/qpxzpw_54t3cstcdz91h7py00000gn/T/easywebpack-cli-init
[easywebpack-cli]:init egg_vue_ssr_ts project successfully!

[easywebpack-cli]:Now, start coding by follow step:
1) cd egg_vue_ssr_ts
2) npm install or yarn install
3) npm run dev or npm start

按README.MD发布,先npm run tsc

$ npm run tsc

> egg_vue_ssr_ts@1.0.0 tsc /Users/lfh/Developer/egg_vue_ssr_ts
> ets && tsc -p tsconfig.json

[egg-ts-helper] create /Users/lfh/Developer/egg_vue_ssr_ts/typings/app/extend/application.d.ts
[egg-ts-helper] create /Users/lfh/Developer/egg_vue_ssr_ts/typings/app/extend/context.d.ts
[egg-ts-helper] create /Users/lfh/Developer/egg_vue_ssr_ts/typings/app/controller/index.d.ts
[egg-ts-helper] create /Users/lfh/Developer/egg_vue_ssr_ts/typings/app/middleware/index.d.ts
[egg-ts-helper] create /Users/lfh/Developer/egg_vue_ssr_ts/typings/app/model/index.d.ts
[egg-ts-helper] create /Users/lfh/Developer/egg_vue_ssr_ts/typings/config/index.d.ts
[egg-ts-helper] create /Users/lfh/Developer/egg_vue_ssr_ts/typings/config/plugin.d.ts
[egg-ts-helper] create /Users/lfh/Developer/egg_vue_ssr_ts/typings/app/service/index.d.ts

然后再npm run build

AssertionError [ERR_ASSERTION]: dynamic create plugin[imagemini] error, please check the npm module [imagemin-webpack-plugin]whether installed. if not installed, please execute below command in command line:

            npm: npm install imagemin-webpack-plugin --save-dev

            cnpm: cnpm install imagemin-webpack-plugin --save-dev

            tnpm: tnpm install imagemin-webpack-plugin --save-dev

            yarn: yarn install imagemin-webpack-plugin --save-dev

按提示安装后,重新build

$ npm run build

> egg_vue_ssr_ts@1.0.0 build /Users/u1/work/egg_vue_ssr_ts
> easy build

clean-webpack-plugin: /Users/u1/work/egg_vue_ssr_ts/public has been removed.
webpack build [=======                                                                  ] 10% (0.0 seconds){ parser: "babylon" } is deprecated; we now treat it as { parser: "babel" }.
webpack build [=======================================================================] 100% (11.2 seconds)

Build completed in 11.218s

webpack build [=======================================================================] 100% (19.5 seconds)

Build completed in 19.556s

Hash: 0d15c6c757aa03d43f52
Version: webpack 4.29.0
Time: 19566ms
Built at: 2019/01/23 上午11:08:53
                           Asset      Size      Chunks  Chunk Names
     css/admin/home.99d61986.css   193 KiB  admin/home  admin/home
font/element-icons.2fad952a.woff  6.02 KiB
 font/element-icons.6f0a7632.ttf  10.8 KiB
 js/chunk/admin/home.6d5c08f0.js   647 KiB  admin/home  admin/home
     js/chunk/common.e5b0f845.js   110 KiB      common  common
          js/runtime.abe9d429.js  1.43 KiB     runtime  runtime

ERROR in ./app/web/page/admin/home/router/index.ts 21:48
Module parse failed: Unexpected token (21:48)
You may need an appropriate loader to handle this file type.
|             {
|                 path: '/article/add',
>                 component: function () { return import('../view/write/index.vue'); }
|             },
|             {
 @ ./app/web/page/admin/home/index.ts 4:0-42 6:79-91
Hash: dfbacb0d001acf089f19
Version: webpack 4.29.0
Time: 11224ms
Built at: 2019/01/23 上午11:08:44
        Asset      Size  Chunks  Chunk Names
admin/home.js  15.8 KiB       0  admin/home

ERROR in ./app/web/page/admin/home/router/index.ts 21:48
Module parse failed: Unexpected token (21:48)
You may need an appropriate loader to handle this file type.
|             {
|                 path: '/article/add',
>                 component: function () { return import('../view/write/index.vue'); }
|             },
|             {
 @ ./app/web/page/admin/home/index.ts 4:0-42 6:79-91
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! egg_vue_ssr_ts@1.0.0 build: `easy build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the egg_vue_ssr_ts@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!     /Users/u1/.npm/_logs/2019-01-23T03_08_53_365Z-debug.log

然后报错了,看到build过程有个提示:{ parser: "babylon" } is deprecated; we now treat it as { parser: "babel" }.

查看对应报错的文件,前端的路由,并无异常,请问该如何解决?

lianfanghua commented 5 years ago

找到问题了,webpack的问题, 等待官方解决,暂时可以通过使用webpack@4.28解决。详见:https://github.com/webpack/webpack/issues/8656