安装coze 库没有报错 npm install @coze/api --save
在云对象中也能使用,但是在客户端报错,
1、用 import { WsToolsUtils } from "@coze/api/ws-tools"; 页面报如下错误。
Failed to resolve import "@coze/api/ws-tools" from "C:/Users/123/Documents/HBuilderProjects/hr/pages/index/websocketRtc.vue". Does the file exist?
2、用const { WsToolsUtils } = require('@coze/api/ws-tools'); 报如下错误:
main.js?t=1745834743272:27 ReferenceError: require is not defined
2 个回复
y***@qq.com (作者)
不好意思,是我自己的问题,uni-app 新手,新装库,需要重启服务,重启就好了。
DCloud_UNI_JBB
可以看看是不是你的路径写错了,另外,如果你写的是vue3,不支持commonjs引入文件
https://uniapp.dcloud.net.cn/tutorial/migration-to-vue3.html#%E5%8F%AA%E6%94%AF%E6%8C%81%E4%BD%BF%E7%94%A8-es6-%E6%A8%A1%E5%9D%97%E8%A7%84%E8%8C%83