getting-started icon indicating copy to clipboard operation
getting-started copied to clipboard

SyntaxError: The requested module 'wechaty' does not provide an export named 'Contact'

Open yigeyanse opened this issue 2 years ago • 2 comments

I use example code ,when i start program ,it get error

code:

import 'dotenv/config.js'

import {
  Contact,
  Message,
  ScanStatus,
  WechatyBuilder,
  log,
} from 'wechaty'

import qrcodeTerminal from 'qrcode-terminal'

function onScan (qrcode, status) {
  if (status === ScanStatus.Waiting || status === ScanStatus.Timeout) {
    const qrcodeImageUrl = [
      'https://wechaty.js.org/qrcode/',
      encodeURIComponent(qrcode),
    ].join('')
    log.info('StarterBot', 'onScan: %s(%s) - %s', ScanStatus[status], status, qrcodeImageUrl)
........


error:
PS D:\个人\getting-started-main> node .\examples\test2.js
file:///D:/%E4%B8%AA%E4%BA%BA/getting-started-main/examples/test2.js:11
  ContactInterface,
  ^^^^^^^^^^^^^^^^
SyntaxError: The requested module 'wechaty' does not provide an export named 'ContactInterface'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:128:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:194:5)
    at async Promise.all (index 0)
    at async handleMainPromise (node:internal/modules/run_main:61:12)

yigeyanse avatar Apr 09 '22 01:04 yigeyanse

Could you please confirm whether you can run npm start with our getting started?

Make sure you are using Node.js 16+ and NPM 7+.

If you can not, please paste the output log message.

huan avatar Apr 09 '22 09:04 huan

import {FileBox, ScanStatus, WechatyBuilder, log } from 'wechaty' ^^^^^^^ SyntaxError: The requested module 'wechaty' does not provide an export named 'FileBox' at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21) at async ModuleJob.run (node:internal/modules/esm/module_job:189:5) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:533:24) at async loadESM (node:internal/process/esm_loader:91:5) at async handleMainPromise (node:internal/modules/run_main:65:12)

版本:

$ npm --version 9.6.0

$ node --version v16.17.0

sunboye avatar Apr 11 '23 15:04 sunboye