koishijs / koishi

Cross-platform chatbot framework made with love
https://koishi.chat
MIT License
4.37k stars 237 forks source link

Bug: Cannot read properties of undefined (reading 'global') #599

Closed Innei closed 2 years ago

Innei commented 2 years ago

Describe the bug

使用 npm init koishi 的模板无法启动,plugin-console 注册失败,Cannot read properties of undefined (reading 'global')


at 16:00:27 ❯ npm init koishi
Need to install the following packages:
  create-koishi
Ok to proceed? (y)

  Create Koishi  v4.2.1

✔ Project Name: … koishi-app
✔ Choose a typescript compiler: › esbuild
  Scaffolding project in koishi-app ...
  Done.

✔ Choose a package manager: › pnpm
✔ Install and start it now? … yes
Packages: +235
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: /Users/xiaoxun/.pnpm-store/v3
  Virtual store is at:             node_modules/.pnpm
Progress: resolved 235, reused 221, downloaded 14, added 235, done
node_modules/.pnpm/esbuild@0.12.29/node_modules/esbuild: Running postinstall script, done in 1.3s

dependencies:
+ @koishijs/cli 4.5.1
+ @koishijs/plugin-adapter-discord 2.0.7
+ @koishijs/plugin-adapter-onebot 4.1.5
+ @koishijs/plugin-adapter-telegram 2.2.1
+ @koishijs/plugin-console 2.2.0 (3.2.4 is available)
+ @koishijs/plugin-dataview 1.2.2
+ @koishijs/plugin-insight 1.3.0
+ @koishijs/plugin-logger 1.2.2
+ @koishijs/plugin-manager 1.6.0
+ @koishijs/plugin-status 5.3.4
+ koishi 4.5.1

devDependencies:
+ esbuild 0.12.29 (0.14.34 is available)
+ esbuild-register 2.6.0 (3.3.2 is available)
+ typescript 4.6.3

 WARN  Issues with peer dependencies found
.
├─┬ @koishijs/plugin-dataview
│ └── ✕ unmet peer @koishijs/plugin-console@^3.2.4: found 2.2.0
├─┬ @koishijs/plugin-insight
│ └── ✕ unmet peer @koishijs/plugin-console@^3.2.4: found 2.2.0
├─┬ @koishijs/plugin-logger
│ └── ✕ unmet peer @koishijs/plugin-console@^3.2.0: found 2.2.0
├─┬ @koishijs/plugin-manager
│ └── ✕ unmet peer @koishijs/plugin-console@^3.2.4: found 2.2.0
└─┬ @koishijs/plugin-status
  └── ✕ unmet peer @koishijs/plugin-console@^3.2.3: found 2.2.0

Steps to reproduce

使用 脚手架 新建项目,选择 pnpm,esbuild

Expected behavior

正常启动

Screenshots

No response

Versions

Additional context

No response

Innei commented 2 years ago

Log:

$ koishi start -- -r esbuild-register
[I] app Koishi/4.5.1
[I] app apply plugin ./src/ping
[I] app apply plugin console
[E] app TypeError: Cannot read properties of undefined (reading 'global')
        at new HttpService (/Users/xiaoxun/github/innei-repo/koishi-app/node_modules/.pnpm/@koishijs+plugin-console@2.1.0_koishi@4.1.2/node_modules/@koishijs/plugin-console/src/http.ts:16:17)
        at callback (/Users/xiaoxun/github/innei-repo/koishi-app/node_modules/.pnpm/@koishijs+core@4.5.1/node_modules/@koishijs/core/src/context.ts:309:26)
        at _Context.plugin (/Users/xiaoxun/github/innei-repo/koishi-app/node_modules/.pnpm/@koishijs+core@4.5.1/node_modules/@koishijs/core/src/context.ts:318:5)
        at new Console (/Users/xiaoxun/github/innei-repo/koishi-app/node_modules/.pnpm/@koishijs+plugin-console@2.1.0_koishi@4.1.2/node_modules/@koishijs/plugin-console/src/index.ts:35:9)
        at callback (/Users/xiaoxun/github/innei-repo/koishi-app/node_modules/.pnpm/@koishijs+core@4.5.1/node_modules/@koishijs/core/src/context.ts:309:26)
        at App.plugin (/Users/xiaoxun/github/innei-repo/koishi-app/node_modules/.pnpm/@koishijs+core@4.5.1/node_modules/@koishijs/core/src/context.ts:318:5)
        at Loader.reloadPlugin (/Users/xiaoxun/github/innei-repo/koishi-app/node_modules/.pnpm/@koishijs+cli@4.1.2/node_modules/@koishijs/cli/src/loader.ts:145:14)
        at Loader.createApp (/Users/xiaoxun/github/innei-repo/koishi-app/node_modules/.pnpm/@koishijs+cli@4.1.2/node_modules/@koishijs/cli/src/loader.ts:155:12)
        at Object.<anonymous> (/Users/xiaoxun/github/innei-repo/koishi-app/node_modules/.pnpm/@koishijs+cli@4.1.2/node_modules/@koishijs/cli/src/worker.ts:21:20)
        at Module._compile (node:internal/modules/cjs/loader:1103:14)
shigma commented 2 years ago

试一下把版本都更新到最新版,主要是 @koishijs/plugin-console。

Innei commented 2 years ago

可以的,最好还是更新一下模板吧,对模板都跑不动的话挺劝退的

shigma commented 2 years ago

模板其实一直是最新的,是不是你项目比较旧,安装的比较早?