尝试创建模板插件时报错

如题,Koishi/4.16.1,node -v20.10.0,npm -10.2.3,yarn -1.22.21。
成功完成了创建模板项目,但是在创建插件时出现如下报错,求教一下如何正确操作

yarn setup @yumeshi/song -G
√ description: … 点歌
node:internal/errors:932
const err = new Error(message);
^

Error: Command failed: git commit -m “initial commit”
at checkExecSyncError (node:child_process:890:11)
at execSync (node:child_process:962:15)
at Initiator.initGit (C:\PAND\order\koishi\try\emochan\node_modules@koishijs\scripts\lib\setup.js:191:38)
at async Initiator.write (C:\PAND\order\koishi\try\emochan\node_modules@koishijs\scripts\lib\setup.js:101:9)
at async Initiator.init (C:\PAND\order\koishi\try\emochan\node_modules@koishijs\scripts\lib\setup.js:74:9)
at async Initiator.start (C:\PAND\order\koishi\try\emochan\node_modules@koishijs\scripts\lib\setup.js:34:9) {
status: 128,
signal: null,
output: [ null, null, null ],
pid: 16484,
stdout: null,
stderr: null
}

目录以及编写测试插件yarn dev启动如下图

[W] config failed to resolve @yumeshi/koishi-plugin-song
[W] config Error: Cannot find module ‘C:\PAND\order\koishi\try\emochan\node_modules@yumeshi\koishi-plugin-song\lib\index.js’. Please verify that the package.json has a valid “main” entry
at tryPackage (node:internal/modules/cjs/loader:444:19)
at Module._findPath (node:internal/modules/cjs/loader:715:18)
at Module._resolveFilename (node:internal/modules/cjs/loader:1130:27)
at Module._resolveFilename (C:\PAND\order\koishi\try\emochan\node_modules\esbuild-register\dist\node.js:4787:36)
at Function.resolve (node:internal/modules/helpers:187:19)
at _PackageScanner.loadPackage (C:\PAND\order\koishi\try\emochan\node_modules@koishijs\registry\src\local.ts:62:29)
at _PackageScanner.loadDirectory (C:\PAND\order\koishi\try\emochan\node_modules@koishijs\registry\src\local.ts:51:18)
at async Promise.all (index 0)
at _PackageScanner._collect (C:\PAND\order\koishi\try\emochan\node_modules@koishijs\registry\src\local.ts:31:5)

1 个赞

按文档操作了吗?

2 个赞

懂了,我是根据BV1pW4y1V7qV,B站的视频教程完成的前半部分,漏掉了git

2 个赞

啊,不好意思还有下面这个问题,插件启动时出现报错

PS C:\PAND\order\koishi\try\emochan> yarn dev
2023-12-18 20:44:28 [I] app Koishi/4.16.1
2023-12-18 20:44:28 [I] loader apply plugin group:entry
2023-12-18 20:44:28 [I] loader apply plugin group:server
2023-12-18 20:44:28 [I] loader apply plugin server:6bwh7u
2023-12-18 20:44:28 [I] loader apply plugin group:basic
2023-12-18 20:44:28 [I] loader apply plugin commands:ms4jdm
2023-12-18 20:44:28 [I] loader apply plugin help:kfdr3q
2023-12-18 20:44:28 [I] loader apply plugin locales:7ptfk9
2023-12-18 20:44:28 [I] loader apply plugin rate-limit:rurmzi
2023-12-18 20:44:28 [I] loader apply plugin telemetry:puea8r
2023-12-18 20:44:28 [I] loader apply plugin group:console
2023-12-18 20:44:28 [I] loader apply plugin actions:te2sjp
2023-12-18 20:44:28 [I] loader apply plugin analytics:d68o22
2023-12-18 20:44:28 [I] loader apply plugin config:mwx873
2023-12-18 20:44:28 [I] loader apply plugin console:eyobgm
2023-12-18 20:44:28 [I] loader apply plugin dataview:hatg4p
2023-12-18 20:44:29 [I] loader apply plugin explorer:sz7etc
2023-12-18 20:44:29 [I] loader apply plugin logger:nf3vop
2023-12-18 20:44:29 [I] loader apply plugin insight:x7q8c1
2023-12-18 20:44:29 [I] loader apply plugin market:53pzmz
2023-12-18 20:44:29 [I] loader apply plugin oobe:kgjm3j
2023-12-18 20:44:29 [I] loader apply plugin sandbox:8pypfs
2023-12-18 20:44:29 [I] loader apply plugin status:3cymcv
2023-12-18 20:44:29 [I] loader apply plugin theme-vanilla:3466m4
2023-12-18 20:44:29 [I] loader apply plugin group:storage
2023-12-18 20:44:29 [I] loader apply plugin database-sqlite:84l2xa
2023-12-18 20:44:29 [I] loader apply plugin assets-local:ostlls
2023-12-18 20:44:29 [I] loader apply plugin group:adapter
2023-12-18 20:44:29 [I] loader apply plugin group:develop
2023-12-18 20:44:29 [I] loader apply plugin hmr:187uc2
2023-12-18 20:44:29 [I] loader apply plugin group:test
2023-12-18 20:44:29 [I] assets missing config “selfUrl”, fallback to “file:” scheme
2023-12-18 20:44:29 [I] server server listening at http://127.0.0.1:5140
2023-12-18 20:44:30 [I] console webui is available at http://127.0.0.1:5140
2023-12-18 20:44:30 [W] config failed to resolve @yumeshi/koishi-plugin-song
2023-12-18 20:44:30 [W] config Error: Cannot find module ‘C:\PAND\order\koishi\try\emochan\node_modules@yumeshi\koishi-plugin-song\lib\index.js’. Please verify that the package.json has a valid “main” entry
at tryPackage (node:internal/modules/cjs/loader:444:19)
at Module._findPath (node:internal/modules/cjs/loader:715:18)
at Module._resolveFilename (node:internal/modules/cjs/loader:1130:27)
at Module._resolveFilename (C:\PAND\order\koishi\try\emochan\node_modules\esbuild-register\dist\node.js:4787:36)
at Function.resolve (node:internal/modules/helpers:187:19)
at _PackageScanner.loadPackage (C:\PAND\order\koishi\try\emochan\node_modules@koishijs\registry\src\local.ts:62:29)
at _PackageScanner.loadDirectory (C:\PAND\order\koishi\try\emochan\node_modules@koishijs\registry\src\local.ts:51:18)
at async Promise.all (index 0)
at _PackageScanner._collect (C:\PAND\order\koishi\try\emochan\node_modules@koishijs\registry\src\local.ts:31:5)
根据我的粗浅观察,很多插件同时包含了.js和.d.ts,比较小白,如果有时间的话求教一下

2 个赞

这个问题很奇怪,理论上不应该出现,可能是你的某一步操作出现了问题

1 个赞


已解决,疑似tsconfig.json修改出错

4 个赞