萌新练手-搓个简单的小blockly-选择

更新近期进展:重新跟着视频学习了blockly的安装和开发,在这里更新一些自己踩的坑。

由于我个人的进度是前三集顺利,主要在第四集开发插件01出现困难,因此内容也会比较集中在开发问题上,可能有遗漏缺失的地方请务必去视频中确认,一切以视频和官方手册为准。

祭出第四集的思维导图:


血泪教训:请跟着视频一点一点一步一步走,千万别跳

问题1:创建插件不成功,安装git一路next但是失败,没有done而是报错,账户没设置。

详情

块引用
x yarn run v1.22.19
$ koishi-scripts setup random
V description: …随机
Initialized empty Git repository in C:/dev/koishi - app/ external/random/ .git/
Author identity unknown
*** Please tell me who you are .
Run
git config – global user . email "you@example . com”
git config --global user .name "Your Name "
to set your account’s default identity .
Omit --global to set the identity only in this repository .
fatal: unable to auto-detect email address (got ’ 1@DESKTOP -N5TH19T. (none)‘)
C: \dev\koishi- app\node_ modules \execa\lib\error .js:60
error = new Error(message);
Error: Command failed with exit code 128: git commit -m initial commit
at makeError (C: \dev\koishi -app\node_ modules \execa\lib\error . js :60:11)
at module . exports . sync (C: \dev\koishi - app\node_ modules lexeca\index.js:194:17)
at Initiator . initGit (C: dev\koishi - app\node_ modules @koishijs \scripts\lib\bin. js:136:26
at async Initiator . write (C: \dev\koishi - app\node_ modules @koishijs\scripts\lib\bin.js:91
at async Initiator .init (C: \dev\koishi-app\node_ modules @koishijs\scripts \lib\bin. js:64:
at async Initiator . start (C: \dev\koishi一app\node_ modules @koishijs\scripts\lib\bin.js:42
shortMessage: ’ Command failed with exit code 128: git commit -m initial commit’ ,
command: ‘git commit -m initial commit’ ,
escapedCommand: ’ git commit -m “initial commit”',
exitCode: 128 ,
signal: undefined,
signalDescription: undefined ,
stdout: undefined ,
stderr: undefined,
failed: true ,
timedout: false ,
isCanceled: false,
killed: false
Node. js v18.14.0
error Command failed with exit code 1
info Visit https://yarnpkg. com/ en/ docs/ cli/run for documentation about this command .

解决:按照报错中提示的命令输入

git config – global user . email "you@example . com”
git config --global user .name "Your Name "

问题2:无法发布插件

详情

块引用
PS C: \dev\koishi-app> npm publish - -workspace koishi -plugin- random-number --access public - -registry
8 npm WARN invalid config registry=true set in command line options
npm WARN invalid config Must be full url with “http://”
npm notice
npm notice koishi - plugin-random- number@o .0.1
npm notice === Tarball Contents ===
npm notice 217B 1ib/ index.d.ts
npm notice 517B lib/index. js
npm notice 352B package . json
npm notice 192B readme . md
npm notice ===
Tarball Details ===
npm notice name:
koishi - plugin- random- number
npm notice version: 0.0.1
npm notice filename :
koishi-plugin-random-number-0.0.1. tgz
npm notice package size: 809 B
npm notice unpacked size: 1.3 kB
npm notice shasum:
1b966420ab13f3047795b14e290f93ad36e6f5ac
npm notice integrity: sha512-Vbu7C9Q12Fgk5[ …]Z/vcU2SLZUbfQ==
npm notice total files: 4
npm notice
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https ://registry . npmmirror. com/
npm ERR! need auth You need to authorize this machine using
npm adduser
npm ERR! A complete log of this run can be found in:
npm ERR!
C: \Users\1 \AppData\Local \npm-cache_ logs \2023-02-15T19_ 22 28_ 644Z-debug 0.1og
。PS C: \dev\koishi-app> npm publish - -workspace koishi -plugin- random-number --access public --registry ^C
。PS C: \dev\koishi -app>[

解决:原因:和已有插件重名了,改个名字再发布

问题3:koishi1里跟着视频找不到文件夹在哪?为什么后续的create new什么的我都看不懂跟不上?为什么我的文件夹是external没有plugin?
解决:1. 这……不算是坑,不过我也没找到解决办法,所以我卸了跟着视频教程和手册重新安装了。一回生二回熟,在反复重装七八遍后已经是安装小能手了!总能成功的!我在后面的每次重装,都会把yarn和node之类的安装流程也重新走一遍,以免出现奇怪的因为安装问题出现的报错。
重装前请妥善导出并保管好您写的blockly插件副本
2. koishi某次更新后把plugin换成了external,咱们就拿external当视频里的plugin用。

问题4:怎么换行
解决:群里佬给出的换行符:


 
 

三选一即可。感觉这个问题还蛮多人问的所以记录一下,以后在论坛里就可以直接搜到了,记得带上分号
ps: 这三个符本来打出来是空格,但是通过帖子编辑右上角的【齿轮-预先格式化的文本】在``里输入就可以显示出字符形态。

问题5:全局设置了。和.,结果只有。能用?

解决:H4M5TER佬和ilharp佬给出了非常详尽的回答。重点在于理解条件配置是什么。
以此问题可以延伸到koishi的各项功能,作为萌新,通常不理解各项的具体功能,找到一个“看起来好像差不多能用”的便拿来试试,于是踩一堆坑。跟着教程和手册一步一步走真的很重要。这些是我把这些无论大小的事都记录下来的目的,作为经验的积累。

7 个赞