finalpi / wechat2tg

微信消息转发到telegram
MIT License
137 stars 15 forks source link

Syntax error #19

Open cloudy-sfu opened 5 days ago

cloudy-sfu commented 5 days ago

After running npm start, there is an error:

> wechat2tg@1.0.0 start
> tsc && node dist/app.js NODE_ENV=production

/home/username/wechat2tg/node_modules/typescript/lib/tsc.js:92
  for (let i = startIndex ?? 0; i < array.length; i++) {
                           ^

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:85:18)
    at Object.<anonymous> (/home/username/wechat2tg/node_modules/typescript/bin/tsc:2:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

How to solve it? Thank you.

areidx commented 4 days ago

What`s your Node.js version? You can try using Node 18+.

cloudy-sfu commented 14 hours ago

Thanks. @areidx My node.js version is 12.22.9, I have now upgraded it to 20.15.0 (stable).

However, when running npm start, it reports:

Cannot find module 'wechaty/impls' or its corresponding type declarations.

Also a lot of places report:

error TS2307: Cannot find module 'wechaty/dist/esm/src/mods/impls' or its corresponding type declarations.

And a lot of variables report:

 Parameter '...' implicitly has an 'any' type.

Then, I tried to install npm install wechaty/impls, but it fails:

node:internal/modules/cjs/loader:1145
  const err = new Error(message);
              ^

Error: Cannot find module 'semver'
Require stack:
- /usr/share/nodejs/npm/lib/utils/unsupported.js
- /usr/share/nodejs/npm/lib/cli.js
- /usr/share/nodejs/npm/bin/npm-cli.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Module._load (node:internal/modules/cjs/loader:986:27)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/usr/share/nodejs/npm/lib/utils/unsupported.js:2:16)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Module.require (node:internal/modules/cjs/loader:1233:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/share/nodejs/npm/lib/utils/unsupported.js',
    '/usr/share/nodejs/npm/lib/cli.js',
    '/usr/share/nodejs/npm/bin/npm-cli.js'
  ]
}

When I try npm install semver it fails as well.

I also followed https://stackoverflow.com/questions/64732623/typescript-cannot-find-module-or-its-corresponding-type-declarations and tried both npm install @types/wechaty and npm install @types/. where . means current folder (wechat2tg), however both fail.

How to solve this problem? Thank you!