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

导入import { Wechaty } from 'wechaty'报错 #2681

Open
aqpmzngldh opened this issue Apr 29, 2024 · 1 comment
Open

导入import { Wechaty } from 'wechaty'报错 #2681

aqpmzngldh opened this issue Apr 29, 2024 · 1 comment

Comments

@aqpmzngldh
Copy link

import { Wechaty } from 'wechaty'
^^^^^^^
SyntaxError: The requested module 'wechaty' does not provide an export named 'Wechaty'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)

Node.js v18.16.0

Copy link

dosubot bot commented Apr 29, 2024

The error you're encountering is due to attempting to import Wechaty directly, which is not how the module exports it. Instead, you should use WechatyBuilder for creating instances of Wechaty. Here's how you can correctly import and use Wechaty in your project:

import { WechatyBuilder } from 'wechaty';

const bot = WechatyBuilder.build({
  // options here
});

This approach aligns with the latest Wechaty documentation and should resolve the import error you're facing. Your Node.js version (v18.16.0) is compatible with Wechaty, as it requires Node.js version ">=16".

Additionally, be aware that the default puppet in Wechaty has recently changed. If your project depends on the default puppet, ensure you're using the correct configuration and dependencies. If issues persist, providing more details about your project setup could help in offering a more specific solution.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

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

No branches or pull requests

1 participant