wechaty / getting-started

A Starter Project Template for Wechaty works out-of-the-box
https://gitpod.io/#https://github.com/wechaty/wechaty-getting-started
Apache License 2.0
774 stars 342 forks source link

Node.js v16+ required: cjs 包语法错误 `timestamp ??= 0` #230

Closed secreter closed 2 years ago

secreter commented 2 years ago

puppet-service 的cjs 包有没有编译的语法,导致执行不了,最新的好多版本都有这个问题。

/bot/node_modules/wechaty/node_modules/wechaty-puppet-service/dist/cjs/src/client/puppet-service.js:1130
        timestamp ??= 0;
                  ^^^

SyntaxError: Unexpected token '??='
huan commented 2 years ago

Wechaty v1.x requires Node.js v16+ & NPM 7+

Please upgrade your Node.js to meet the requirement.

See:

xmsz commented 2 years ago

same promblem

node -v
v16.15.0
npm -v
8.5.5

{
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "wechaty": "^1.18.1"
  }
}
s-node ./src/index.ts
node_modules/.pnpm/wechaty-puppet-service@1.18.2_d42f159a7024166bfd1a952a1deb1e77/node_modules/wechaty-puppet-service/dist/cjs/src/client/puppet-service.js:1165
        timestamp ??= 0;
                  ^^^

SyntaxError: Unexpected token '??='
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/node_modules/.pnpm/wechaty-puppet-service@1.18.2_d42f159a7024166bfd1a952a1deb1e77/node_modules/wechaty-puppet-service/src/mod.ts:4:1)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
huan commented 2 years ago

@xmsz If you believe you are using Node.js v16+, then a reproducible repo would be helpful.

Or you can clone this repo and run npm start, it will run without any problem.

xmsz commented 2 years ago

My problom... it works fine

huan commented 2 years ago

Great to know that,I hoped you enjoy your chatbot soon!

xmsz commented 2 years ago

Great to know that,I hoped you enjoy your chatbot soon!

hope so, but i met some problem

(in Chinese)

  1. 刚开始用puppter-wechat,发生我的测试微信号是新号,没办法使用web协议
  2. 尝试putter-padlocal/putter-padsimple,但是发送这两个项目都是0.x和wechaty1.x不兼容

现在只能先把wechaty降到0.x 然后看看能不能跑