wangrongding / wechat-bot

🤖一个基于 WeChaty 结合 OpenAi ChatGPT / Kimi / 讯飞等Ai服务实现的微信机器人 ,可以用来帮助你自动回复微信消息,或者管理微信群/好友,检测僵尸粉等...
MIT License
4.96k stars 710 forks source link

npm 7.21.1 node16.9.1 Ubuntu 22.04.1 LTS can not run, because The requested module 'wechaty' is a CommonJS module, which may not support all module.exports as named exports. Could every body tell me why? #27

Closed slongli closed 5 months ago

slongli commented 1 year ago

import { WechatyBuilder, ScanStatus, log } from "wechaty"; ^^^^^^^^^^^^^^ SyntaxError: Named export 'WechatyBuilder' not found. The requested module 'wechaty' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:

import pkg from 'wechaty'; const { WechatyBuilder, ScanStatus, log } = pkg;

at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:179:5)
at async Loader.import (node:internal/modules/esm/loader:178:24)
at async Object.loadESM (node:internal/process/esm_loader:68:5)
at async handleMainPromise (node:internal/modules/run_main:63:12)
wangrongding commented 1 year ago

Try using the node LTS version

ronaldox commented 1 year ago

Try using the node LTS version

我和他是一样的错,更换了nodejs最新LTS版本也不行

slongli commented 1 year ago

我应该是这样解决了,你试试,sudo npm install qrcode-terminal --save sudo npm install wechaty sudo npm install wechaty-puppet-wechat --save

------------------ Original message ------------------ From: "ronaldox"; Sendtime: Tuesday, Dec 13, 2022 2:28 AM To: "wangrongding/wechat-bot"; Cc: " @.***>; "Author"; Subject: Re: [wangrongding/wechat-bot] npm 7.21.1 node16.9.1 Ubuntu 22.04.1 LTS can not run, because The requested module 'wechaty' is a CommonJS module, which may not support all module.exports as named exports. Could every body tell me why? (Issue #27)

Try using the node LTS version

我和他是一样的错,更换了nodejs最新LTS版本也不行

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

wangrongding commented 1 year ago

或者先参考这个方案。 https://github.com/wangrongding/wechat-bot/issues/54#issuecomment-1347743629