wechaty / puppet-supports

Wechaty Puppet Services (WPS)
https://wechaty.js.org/docs/puppet-services/
Apache License 2.0
33 stars 4 forks source link

[BUG]WorkPro: ts-node index.ts TSError: ⨯ Unable to compile TypeScript: index.ts:70:19 - error TS2552: Cannot find name 'URL'. Did you mean 'url'? #525

Open luojingwenaihemiao opened 4 months ago

luojingwenaihemiao commented 4 months ago

Please make sure you have read the Wechaty Puppet Service: WorkPro from Wechaty Official Website before you continue writing this issue.

--- YES, I have checked with that already.

Describe the bug

Follow #267 to try the codespace. After command the npm start, it shows up following error log:

$ npm start

workpro-getting-started@1.0.0 start ts-node index.ts

/usr/local/share/nvm/versions/node/v20.15.1/lib/node_modules/ts-node/src/index.ts:859 return new TSError(diagnosticText, diagnosticCodes, diagnostics); ^ TSError: ⨯ Unable to compile TypeScript: index.ts:70:19 - error TS2552: Cannot find name 'URL'. Did you mean 'url'?

70 const url = new URL(urlStr);


  index.ts:70:9
    70   const url = new URL(urlStr);
'url' is declared here.

at createTSError (/usr/local/share/nvm/versions/node/v20.15.1/lib/node_modules/ts-node/src/index.ts:859:12)
at reportTSError (/usr/local/share/nvm/versions/node/v20.15.1/lib/node_modules/ts-node/src/index.ts:863:19)
at getOutput (/usr/local/share/nvm/versions/node/v20.15.1/lib/node_modules/ts-node/src/index.ts:1077:36)
at Object.compile (/usr/local/share/nvm/versions/node/v20.15.1/lib/node_modules/ts-node/src/index.ts:1433:41)
at Module.m._compile (/usr/local/share/nvm/versions/node/v20.15.1/lib/node_modules/ts-node/src/index.ts:1617:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Object.require.extensions.<computed> [as .ts] (/usr/local/share/nvm/versions/node/v20.15.1/lib/node_modules/ts-node/src/index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Function.Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12) {

diagnosticCodes: [ 2552 ]

Info

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://github.com/wechaty/puppet-supports/issues/267
  2. Scroll down to '可运行实例'
  3. Click on codespace
  4. run 'nom start' in code space console
  5. See error

Expected behavior

Shows up the QR-code for logging on with Wecom account.

Screenshots

N/A

su-chang commented 4 months ago

相关依赖没有导致

luojingwenaihemiao commented 4 months ago

感谢回复!可是你们提供的GitHub codespace已经自动安装了相关的依赖了呀?具体还缺少什么依赖呢?谢谢!

@@. / @@.

------------------ Original ------------------ From: SuperChang @.> Date: Sat,Jul 27,2024 9:50 PM To: wechaty/puppet-supports @.> Cc: luojingwenaihemiao @.>, Author @.> Subject: Re: [wechaty/puppet-supports] [BUG]WorkPro: ts-node index.ts TSError: ⨯ Unable to compile TypeScript: index.ts:70:19 - error TS2552: Cannot find name 'URL'. Did you mean 'url'? (Issue #525)

相关依赖没有导致

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

lspbeyond commented 3 months ago

我也遇到了,没写过node代码,搞了个挫的代替下:

const getQrcodeKey = (urlStr: string) => { const url = new URL(urlStr); return url.searchParams.get('key'); } 改成: const getQrcodeKey = (urlStr: string) => { const str_begin = "key=" const str_end = "&" const index_begin = urlStr.indexOf(str_begin); const index_end = urlStr.indexOf(str_end); const str_key = urlStr.slice(index_begin+4, index_end) console.log(str_key) return str_key

}

zhongyuanhui commented 2 months ago

workpro-getting-started@1.0.0 start ts-node index.ts

/workspaces/workpro-getting-started/node_modules/ts-node/src/index.ts:859 return new TSError(diagnosticText, diagnosticCodes, diagnostics); ^ TSError: ⨯ Unable to compile TypeScript: index.ts:70:19 - error TS2552: Cannot find name 'URL'. Did you mean 'url'?

70 const url = new URL(urlStr);


  index.ts:70:9
    70   const url = new URL(urlStr);
'url' is declared here.

at createTSError (/workspaces/workpro-getting-started/node_modules/ts-node/src/index.ts:859:12)
at reportTSError (/workspaces/workpro-getting-started/node_modules/ts-node/src/index.ts:863:19)
at getOutput (/workspaces/workpro-getting-started/node_modules/ts-node/src/index.ts:1077:36)
......
dususu commented 14 hours ago

谢谢回复!但是你们提供的GitHub codespace已经自动安装了相关的依赖了呀?具体还缺什么依赖呢?谢谢!@@. / @@. ------------------ Original ------------------ From: SuperChang @.> Date: Sat,Jul 27,2024 9:50 PM To: wechaty/puppet-supports @.> Cc: luojingwenaihemiao @.>, Author @.> Subject: Re: [wechaty/puppet-supports] [BUG]WorkPro: ts-node index.ts TSError: ⨯ Unable to compile TypeScript: index.ts:70:19 - error TS2552: Cannot find name 'URL'. Did you mean 'url'? (Issue #525) 相关依赖没有导致 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

一样遇到 文档和粑粑一样 一步一坑