首页 / 浏览问题 / WebGIS / 问题详情
关于引入@supermap/iclient-ol 报错
zbb
11EXP 2022年10月20日

iClient-JavaScript/src/openlayers at master · SuperMap/iClient-JavaScript · GitHub

vue3 默认项目 只引入@supermap/iclient-ol 

报错内容

ERROR in ./node_modules/elasticsearch/src/lib/utils.js 2:16-31
Module not found: Error: Can't resolve 'util' in 'E:\My\superdemo\node_modules\elasticsearch\src\lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }
 @ ./node_modules/elasticsearch/src/lib/client.js 32:12-30
 @ ./node_modules/elasticsearch/src/elasticsearch.js 12:12-35
 @ ./node_modules/@supermap/iclient-common/thirdparty/elasticsearch/ElasticSearch.js 5:0-31 35:26-35
 @ ./node_modules/@supermap/iclient-common/thirdparty/elasticsearch/index.js 4:0-46 6:0-23
 @ ./node_modules/@supermap/iclient-common/thirdparty/index.js 4:0-48 6:0-25
 @ ./node_modules/@supermap/iclient-common/index.common.js 309:0-45 704:0-25
 @ ./node_modules/@supermap/iclient-ol/index.js 4:0-54 4:0-54
 @ ./node_modules/@supermap/iclient-ol/namespace.js 141:0-24 141:0-24
 @ ./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/App.vue?vue&type=script&lang=js 7:0-62 20:23-27
 @ ./src/App.vue?vue&type=script&lang=js 1:0-122 1:0-122 1:123-234 1:123-234
 @ ./src/App.vue 2:0-54 3:0-49 3:0-49 8:49-55
 @ ./src/main.js 2:0-27 4:10-13

webpack compiled with 4 errors

3 个回答

您好,在编译时,将忽略的包也进行编译,同时也需要安装缺失的包,执行如下命令:

npm install util

希望可以给您提供帮助!

451EXP 2022年10月20日

超图引入bug: @supermap/iclient-ol 引入超图后项目2134 (gitee.com)

我安装这个后也没用 这是那个仓库

vue create demo

初始化后仅安装 @supermap/iclient-ol 和 util

有空麻烦帮忙看一下 万分感谢

关于如何基于Vue快速搭建超图二维iClient开发环境,可以参考我们的博客:https://blog.csdn.net/supermapsupport/article/details/109294147 和iClient官网中的各种产品对应的开发指南。

451EXP 2022年11月21日

您好!

根据您的报错信息来看,在引入包的过程中,存在部分缺失的情况,您可以继续使用 npm 指令进行针对性地补充,如:npm install util。

了解更多关于 iClient for OpenLayers 使用的内容,您可以前往 :

iClient官网:https://iclient.supermap.io/web/introduction/openlayersDevelop.html

SuperMapSupport CSDN博客:https://blog.csdn.net/supermapsupport

GIS学堂:http://edu.supermap.com/#/

希望可以帮助到您!

485EXP 2022年11月22日
...