lobehub / lobe-cli-toolbox

🪀 Lobe CLI Toolbox - AI CLI Toolbox, enhancing git commit and i18n workflow efficiency
MIT License
261 stars 45 forks source link

[Question] 依赖问题 #4

Closed WyInnovate closed 1 year ago

WyInnovate commented 1 year ago

🧐 问题描述 | Proposed Solution

求助,遇到如下报错

Error: Invalid environment; fetch is not defined
    at new ChatGPTAPI (file:///C:/Users/***/AppData/Roaming/npm/node_modules/@lobehub/commit-cli/node_modules/chatgpt/build/index.js:174:13)
等等

📝 补充信息 | Additional Information

没查到怎么解决这个问题,希望大佬不要打我emmm

canisminor1990 commented 1 year ago

重新全局安装下,升级到最新的包 v1.1.1,昨天有个版本依赖有问题,如果还是同样报错请留言 😝

WyInnovate commented 1 year ago

@canisminor1990

环境说明

笔记本电脑、系统:win11专业版22621.1702、openai key已设置、使用默认openai地址、git仓库为本地服务器自建gitlab

操作说明

重新安装

npm install -g @lobehub/commit-cli

使用

  1. 在D:\Git项目\lobe目录cmd
  2. git add .
  3. lobe
  4. 选择Use AI Commit
  5. 报错,报错内容如下:
    
    D:\Git项目\lobe>lobe

Generating...

Error: Invalid environment; fetch is not defined at new ChatGPTAPI (file:///C:/Users//AppData/Roaming/npm/node_modules/@lobehub/commit-cli/node_modules/chatgpt/build/index.js:174:13) at M (file:///C:/Users//AppData/Roaming/npm/node_modules/@lobehub/commit-cli/dist/cli.js:3:862) at file:///C:/Users//AppData/Roaming/npm/node_modules/@lobehub/commit-cli/dist/cli.js:3:2438 at commitHookEffectListMount (C:\Users\\AppData\Roaming\npm\node_modules\@lobehub\commit-cli\node_modules\react-reconciler\cjs\react-reconciler.development.js:14778:26) at commitPassiveMountOnFiber (C:\Users*\AppData\Roaming\npm\node_modules\@lobehub\commit-cli\node_modules\react-reconciler\cjs\react-reconciler.development.js:16609:11) at commitPassiveMountEffects_complete (C:\Users*\AppData\Roaming\npm\node_modules\@lobehub\commit-cli\node_modules\react-reconciler\cjs\react-reconciler.development.js:16569:9) at commitPassiveMountEffects_begin (C:\Users*\AppData\Roaming\npm\node_modules\@lobehub\commit-cli\node_modules\react-reconciler\cjs\react-reconciler.development.js:16556:7) at commitPassiveMountEffects (C:\Users*\AppData\Roaming\npm\node_modules\@lobehub\commit-cli\node_modules\react-reconciler\cjs\react-reconciler.development.js:16544:3) at flushPassiveEffectsImpl (C:\Users*\AppData\Roaming\npm\node_modules\@lobehub\commit-cli\node_modules\react-reconciler\cjs\react-reconciler.development.js:19182:3) at flushPassiveEffects (C:\Users*\AppData\Roaming\npm\node_modules\@lobehub\commit-cli\node_modules\react-reconciler\cjs\react-reconciler.development.js:19127:14)

# 其他问题
1. 选择 📝 docs  - Add or update README and documentation
2. 输入all
3. 输入测试
4. 输入No
5. 报错,报错内容:

D:\Git项目\lobe>lobe ⠋ Committing... [main 9479ffd] 📝 docs(all): 测试 [#No] 1 file changed, 0 insertions(+), 0 deletions(-)

ERROR The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received undefined

node:internal/errors:387:5

canisminor1990 commented 1 year ago

应该是 node 18 以下 fetch polyfill 问题,我把依赖添加上了,你可以更新下或者升级 node 版本试试

WyInnovate commented 1 year ago

应该是 node 18 以下 fetch polyfill 问题,我把依赖添加上了,你可以更新下或者升级 node 版本试试

已知问题情况

问题1:Error: Invalid environment; fetch is not defined

  1. 更新lobe-commit,问题未解决
  2. 升级node 版本到18.16.0,问题解决

    问题2:ERROR The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received undefined

  3. 更新lobe-commit,问题解决

    新增问题

  4. 更新lobe-commit后,选择 📝 docs - Add or update README and documentation,输入信息时输入英文非常卡顿、慢,并且如果删除输入的内容过快(比如按住Backspace键或者快速多次点击Backspace键),会出现多余字符h同时删除非常卡顿、慢
  5. 不输入OpenAI 的转发地址的话,即使笔记本电脑使用了代理软件比如v2rayN设置好api.openai.com走代理(非全局代理),也不会走代理,然后报错,报错内容应该就是指连接不上接口,报错内容如下:
    TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11457:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.then.promptTokens (file:///C:/Users/***/AppData/Roaming/npm/node_modules/@lobehub/commit-cli/node_modules/chatgpt/build/index.js:298:25)
  6. 使用lobe-coomit --init后,使用Use AI Commit - generate commit message by ChatGPT,会滚动出现无数的Generating,然后生成提交信息后也会重影,选择Use this message后出现hint: Waiting for your editor to close the file...,然后会弹出vscode编辑界面(这个弹出vscode编辑界面是基于默认应用吗?我想大概是,啊跑题了),图片如下所示: 1 2 3
canisminor1990 commented 1 year ago
  1. 如果 [3] 无法解决,我可以看看渲染性能优化的问题
  2. termianl 不会跟随系统代理,要单独设置,除非前置如路由侧就代理了
  3. windows 下如果是用原装 terminal 最好使用 windows terminal + powershell 7 内核,渲染比较好,不会出现这种重影换行
WyInnovate commented 1 year ago
  1. 如果 [3] 无法解决,我可以看看渲染性能优化的问题
  2. termianl 不会跟随系统代理,要单独设置,除非前置如路由侧就代理了
  3. windows 下如果是用原装 terminal 最好使用 windows terminal + powershell 7 内核,渲染比较好,不会出现这种重影换行

环境说明

windows 下:PowerShell 7.4.0-preview.3、PowerShell 7.3.4

测试情况说明

使用 windows terminal + powershell 7 内核 7.4.0-preview.3和PowerShell 7.3.4:

  1. 渲染性能无变化仍然卡顿、慢、删除时会出现字母h2
  2. 重影现象仍然存在,如下图所示 1
canisminor1990 commented 1 year ago

https://github.com/canisminor1990/lobe-commit/assets/17870709/08da4374-7415-4d6c-bf14-9a2d5e82916a

@s544838371 增加了防抖,之前确实在长按退格时会出现卡顿,但还是无法复现重影

WyInnovate commented 1 year ago

@canisminor1990

测试情况说明

2023.5.30更新后已知问题

  1. 重影问题,重影出现的前提是使用hook即,lobe -i,然后git commit的时候就会出现

    录屏

    https://github.com/lobehub/commit-cli/assets/40713819/077eb6d6-e5c5-4119-b317-0fbe29cd8308