安装Yapi-plugin-export-docx-data后无法使用YApi


安装完Yapi-plugin-export-docx-data后网页打开空白,F12打开Console报如下错误

Uncaught SyntaxError: Identifier 'Buffer' has already been declared

安装Yapi-plugin-export-docx-data时编译客户端报如下错误

Module parse failed: C:\WORKSPACE\PublishSite\my-yapi\vendors\node_modules\swagger-client\lib\resolver.js Unexpected token (123:38)
You may need an appropriate loader to handle this file type.
Module parse failed: C:\WORKSPACE\PublishSite\my-yapi\vendors\node_modules\buffer\index.js Unexpected token (1216:24)
You may need an appropriate loader to handle this file type.

 

根据issue二次开发运行或打包报swagger-client/lib/http.js等Module parse failed错误 · Issue #1865 · YMFE/yapi (github.com)

在yapi.config.js文件中添加如下代码,注意报Module parse failed错误的几个路径,我这边是node_modules/swagger-client和node_modules/buffer所以要对这两个路径进行设置。

     baseConfig.module.preLoaders.push({
          test: /\.(js|jsx)$/,
          include: [path.resolve(__dirname, './node_modules/swagger-client')],
          loader: 'babel-loader'
        });

     baseConfig.module.preLoaders.push({
          test: /\.(js|jsx)$/,
          include: [path.resolve(__dirname, './node_modules/buffer')],
          loader: 'babel-loader'
        });
 

重新安装后可以正常打开页面,导出docx

注意,导出word需要有模板。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM