tiddly-gittly / TidGi-Desktop

TidGi is an privacy-in-mind, automated, auto-git-backup, freely-deployed knowledge management Desktop note app, based on Tiddlywiki, with REST API for web-clipping and Anki connect. 「 太记 」是一个基于「 太微 TiddlyWiki 」的知识管理桌面应用,能保护隐私内容、高级自动化、自动Git云备份、部署为博客,且可通过RESTAPI与Anki等应用连接。(迭代开发中欢迎试用,开发进度见下方链接)(Under active development, see website below for details)
https://tidgi.fun
Mozilla Public License 2.0
1.71k stars 106 forks source link

feature: 安装TidGi开发与依赖环境的Q&A #292

Closed Zacharia2 closed 1 year ago

Zacharia2 commented 1 year ago

Description 描述

在clone项目并搭建开发环境时遇到的问题、注意点及解决方案

  1. 使用虚拟机安装原生的Linux环境是最简单有效且问题少的最佳选择。
  2. 安装vm虚拟机、Linux Mint并安装nvm(nodejs版本管理器)Linux版nvm安装地址https://github.com/nvm-sh/nvm#installing-and-updating 如果出现安装完成nvm命令提示未找到,可以关闭当前窗口在打开一个(官网是这样说的,我试过没问题)。然后使用nvm安装nodejs(TidGi Version v0.7.9,Node Version: 16.15.0)
  3. 在nodejs中安装node-gyp,需要先安装g++(建议使用官方源安装,wsl中使用第三方源可能会出现依赖问题无法安装)、python最新版、make,然后再使用node-gyp configure 配置它使它通过检查。
  4. 修改npm源为淘宝源:https://blog.csdn.net/Aria_Miazzy/article/details/106187406
设置NPM/Electron国内源
npm config set registry https://registry.npm.taobao.org
npm config set disturl https://npm.taobao.org/dist
npm config set electron_mirror https://npm.taobao.org/mirrors/electron/

一定要看electron官方文档 了解调试,主线程与渲染线程,主线程与渲染线程之间的通信,主线程的生命周期。消息机制等概念。

Zacharia2 commented 1 year ago

在vscode中执行npm start时发生的错误: An unhandled rejection has occurred inside Forge: Error: Cannot find module 'C:\Users\Mxun\Desktop\TidGi-Desktop\node_modules\iconv-lite\lib\index.js'. Please verify that the package.json has a valid "main" entry

Electron Forge was terminated. Location: {}

花了4个小时处理所有依赖问题,还没弄好。。。

Zacharia2 commented 1 year ago

执行 npm rebuild 重构一下依赖。试试可不可行。

linonetwo commented 1 year ago

用 nvm use 就能使用 .nvmrc 里声明的版本了

然后安装依赖是 npm i

linonetwo commented 1 year ago

别的问题我都没遇到过,可能就是因为没有 npm i ?

Zacharia2 commented 1 year ago

直接在太记根目录输入nvm use 提示无效版本。所以我都是输入具体的

Zacharia2 commented 1 year ago

别的问题我都没遇到过,可能就是因为没有 npm i ?

每次都会使用它安装依赖,每次都会出现上面几种情况。。。( ๑ŏ ﹏ ŏ๑ )

Zacharia2 commented 1 year ago

nvm use 16.15.0

npm i

错误,修错

npm i

错误,修错

依赖安装成功

npm start

非vscode,报错,试图修复,失败从来。

在vscode中 npm start

报错模块不存在。。。(•̩̩̩̩_•̩̩̩̩)

Zacharia2 commented 1 year ago

image

Zacharia2 commented 1 year ago

PS C:\Users\Mxun\Desktop\TidGi-Desktop> npm rebuild npm ERR! code 1 npm ERR! path C:\Users\Mxun\Desktop\TidGi-Desktop\node_modules\registry-js npm ERR! command failed npm ERR! command C:\Windows\system32\cmd.exe /d /s /c prebuild-install || node-gyp rebuild npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@9.1.0 npm ERR! gyp info using node@16.15.0 | win32 | x64 npm ERR! gyp info find Python using Python version 3.10.5 found at "D:\Software\Scoop\apps\python\current\python.exe" npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details npm ERR! gyp ERR! find VS looking for Visual Studio 2015 npm ERR! gyp ERR! find VS - not found npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8 npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS ** npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload. npm ERR! gyp ERR! find VS For more information consult the documentation at: npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows npm ERR! gyp ERR! find VS ** npm ERR! gyp ERR! find VS npm ERR! gyp ERR! configure error npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use npm ERR! gyp ERR! stack at VisualStudioFinder.fail (C:\Users\Mxun\Desktop\TidGi-Desktop\node_modules\node-gyp\lib\find-visualstudio.js:122:47) npm ERR! gyp ERR! stack at C:\Users\Mxun\Desktop\TidGi-Desktop\node_modules\node-gyp\lib\find-visualstudio.js:75:16 npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\Users\Mxun\Desktop\TidGi-Desktop\node_modules\node-gyp\lib\find-visualstudio.js:364:14) npm ERR! gyp ERR! stack at C:\Users\Mxun\Desktop\TidGi-Desktop\node_modules\node-gyp\lib\find-visualstudio.js:71:14 npm ERR! gyp ERR! stack at C:\Users\Mxun\Desktop\TidGi-Desktop\node_modules\node-gyp\lib\find-visualstudio.js:385:16 npm ERR! gyp ERR! stack at C:\Users\Mxun\Desktop\TidGi-Desktop\node_modules\node-gyp\lib\util.js:54:7 npm ERR! gyp ERR! stack at C:\Users\Mxun\Desktop\TidGi-Desktop\node_modules\node-gyp\lib\util.js:33:16 npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:406:5) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28) npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1092:16) npm ERR! gyp ERR! System Windows_NT 10.0.19044 npm ERR! gyp ERR! command "D:\Software\Scoop\apps\nvm\current\nodejs\nodejs\node.exe" "C:\Users\Mxun\Desktop\TidGi-Desktop\node_modules\node-gyp\bin\node-gyp.js" "rebuild" npm ERR! gyp ERR! cwd C:\Users\Mxun\Desktop\TidGi-Desktop\node_modules\registry-js npm ERR! gyp ERR! node -v v16.15.0 npm ERR! gyp ERR! node-gyp -v v9.1.0 npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Mxun\AppData\Local\npm-cache_logs\2022-11-01T10_28_48_017Z-debug-0.log

Zacharia2 commented 1 year ago

在我的电脑上估计是缺少了什么所以无法运行,调试也做不了。如果没有办法的话,那自己尝试增加导入单文件wiki的功能就只能出师未捷身先死了<(。_。)>

Zacharia2 commented 1 year ago

不过如果浏览器可以运行这几个命令的话 $tw.commands.savewikifolder $tw.commands.load $tw.commands.rendertiddler

或许可以写个插件,用浏览器运行。不知道浏览器可以不可,感觉有点不行。

Zacharia2 commented 1 year ago

或许可以抄一下别人的图片本地存储的插件

linonetwo commented 1 year ago

% nvm use
Found '/Users/linonetwo/Desktop/repo/TiddlyGit-Desktop/.nvmrc' with version Now using node v16.13.0 (npm v8.3.2)

这样可以的呀

linonetwo commented 1 year ago

这样,你先把 node_modules 删了,再重新 npm i

记得先配好 https://blog.csdn.net/Aria_Miazzy/article/details/106187406 https://blog.csdn.net/AkitoSilver/article/details/90372230 这些国内镜像,可能之前是安装失败了

linonetwo commented 1 year ago

哦对了,你在 windows 上,需要安装最新版的 visual studio 提供的各种编译环境,因为 node-gyp 会调用这些 c++  python 的东西来编译一些 c++ 写的库。

linonetwo commented 1 year ago

npm ERR! gyp ERR! find VS looking for Visual Studio 2015

说的是 Visual Studio ,不是 vscode

Zacharia2 commented 1 year ago

三克油,林大大,下课去试试

Zacharia2 commented 1 year ago

npm install 错误 gyp ERR! configure error

LINUX的解决方案:https://segmentfault.com/a/1190000040720022?utm_source=sf-similar-article

window好像很少可以找到

Zacharia2 commented 1 year ago

gyp ERR!与node-pre-gyp ERR!报错解决

https://zhuanlan.zhihu.com/p/345314156

Zacharia2 commented 1 year ago

Linux配置好或许比Windows强很多吧。

Zacharia2 commented 1 year ago

一开始的想法是太记有nodejs环境,或许可以免去安装nodejs环境的步骤,使用太记的nodejs环境运行TiddlyWiki命令转换HTML版本与文件夹版本。

Zacharia2 commented 1 year ago

整理一下相关的学到的资料链接:

javascript设计模式——命令模式:https://www.cnblogs.com/xiaohuochai/archive/2017/12/14/8034617.html

electron 渲染进程(web 页面)和主进程 通信 之(ipcMain,ipcRenderer):https://www.jianshu.com/p/61bc90092320

cm = new $tw.commands.savewikifolder.Command(wiki文件夹路径,commander,回调) cm.execute()

linonetwo commented 1 year ago

现在报啥错

参考 https://www.chenhuojun.com/2020/07/12/%E4%B8%BAnode-gyp%E9%85%8D%E7%BD%AE%E6%9C%AC%E5%9C%B0%E7%BC%96%E8%AF%91%E7%8E%AF%E5%A2%83/ 检查一下环境

linonetwo commented 1 year ago

现在唯一的问题就是 node gyp 的了吧,其实如果你有 wsl2 的话,应该会方便一些

Zacharia2 commented 1 year ago

可以装一个试试看

Zacharia2 commented 1 year ago

主要是说配置文件不存在

linonetwo commented 1 year ago

是说类似 Please verify that the package.json has a valid "main" entry 这种吗,这就是 npm i 的过程没装好,可能就是 node-gyp 没成功,就是因为它的环境依赖还没满足

linonetwo commented 1 year ago

所以很多前端开发者还是选择用 mac 或者 linux …

Zacharia2 commented 1 year ago

2019180634-614b1179e8109 这是在网上找的,类似这种的错误。 上午刚刚把wsl安装好。

linonetwo commented 1 year ago

node-gyp 在 linux 环境下比较好配,注意准备好各种环境再 npm i 或者 rebuild

Zacharia2 commented 1 year ago

nvm use在新的Linux中需要指定具体的nodejs版本,默认使用此版本的最新版。 Found '/mnt/c/Users/Mxun/Desktop/TidGi-Desktop/.nvmrc' with version Now using node v16.18.0 (npm v8.19.2) Creating default alias: default -> v16 (-> v16.18.0)

v16.18.0版本过于新了,无法安装依赖。在Windows中执行nvm use没反应。

linonetwo commented 1 year ago

windows 的 nvm 和 linux 的不一样,可能需要先 nvm install v16 ,反正是最新版就行

Zacharia2 commented 1 year ago

npm i npm ERR! code ENOTEMPTY npm ERR! syscall rename npm ERR! path /mnt/c/Users/Mxun/Desktop/TidGi-Desktop/node_modules/ajv-formats npm ERR! dest /mnt/c/Users/Mxun/Desktop/TidGi-Desktop/node_modules/.ajv-formats-uGLUafrW npm ERR! errno -39 npm ERR! ENOTEMPTY: directory not empty, rename '/mnt/c/Users/Mxun/Desktop/TidGi-Desktop/node_modules/ajv-formats' -> '/mnt/c/Users/Mxun/Desktop/TidGi-Desktop/node_modules/.ajv-formats-uGLUafrW'

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2022-11-03T13_15_00_858Z-debug-0.log

Zacharia2 commented 1 year ago

node-gyp单独全局安装成功了。

Zacharia2 commented 1 year ago

有时候执行npm i 会卡死在 idealTree: timing idealTree Completed in 当我不做任何动作执行第二遍时候就跑起来但会出错, npm ERR! code ENOTEMPTY npm ERR! syscall rename

image

npm源是配置的淘宝的那个

Zacharia2 commented 1 year ago

image

linonetwo commented 1 year ago

idealTree 的时候要等,杀了之后就会出错,得删掉 nodemodules 重装了

开始 npm i 之前一定要配好代理

linonetwo commented 1 year ago

你可以看网络情况,它其实是在下载东西和梳理

Zacharia2 commented 1 year ago

删掉 nodemodules 重装好像可以使用这个命令 npm ci

linonetwo commented 1 year ago

那个会忽视 devdeps ,开发不能用

Zacharia2 commented 1 year ago

你可以看网络情况,它其实是在下载东西和梳理

卡死期间好像没有流量,不像之前一样,过几十秒就执行下个,而是过几十分钟都不带动一下的。

Zacharia2 commented 1 year ago

那个会忽视 devdeps ,开发不能用

原来是这样呀。

Zacharia2 commented 1 year ago

可能是学校网络速度太慢了吧,不想安装依赖了,呜呜呜,太难了,等假期回家试试看。谢谢林大大指点

Zacharia2 commented 1 year ago

建议先使用npm install -g node-gyp全局安装这个,然后使用node-gyp configure为当前平台生成合适的项目构建文件。并根据提示解决依赖问题。https://www.cnblogs.com/kihyou/p/13543156.html

补充nodejs的node-gyp,,Python最新版,c/c++编译器g++与make

https://github.com/nodejs/node-gyp#installation

解决g++安装依赖问题:使用官方源安装g++,第三方源可能会出现依赖问题。

linonetwo commented 1 year ago

那可能是需要翻,或者配上各种源,参考上面发的 #292

Zacharia2 commented 1 year ago

改用yarn install可以解决idealTree: timing idealTree Completed in 756ms的卡死问题。

yarn的安装和使用:https://blog.csdn.net/yw00yw/article/details/81354533

Zacharia2 commented 1 year ago

gyp: binding.gyp not found (cwd: /mnt/c/Users/Mxun/Desktop/TidGi-Desktop) while trying to load binding.gyp

好像有个解决方案:https://github.com/nodejs/node-gyp/issues/1709

linonetwo commented 1 year ago

可以先用 yarn ,别把 yarnlock 提交上来就行。

gyp 相关出问题,最简单就是删了 nodemodules 里相关的库然后重新 npm i

在 wsl2 里配会简单很多,linux自带很多开发环境。我自己的 windows 上没遇到过这些问题,因为我是先配好了环境才开始安装的吧。

Zacharia2 commented 1 year ago

可以先用 yarn ,别把 yarnlock 提交上来就行。

gyp 相关出问题,最简单就是删了 nodemodules 里相关的库然后重新 npm i

在 wsl2 里配会简单很多,linux自带很多开发环境。我自己的 windows 上没遇到过这些问题,因为我是先配好了环境才开始安装的吧。

已经解决了,显示ok。还是得先安装gyp呀,使它的配置显示ok,依赖配置的步骤在一楼更新了一下。binding.gyp文件缺失的问题按照上面的链接给的新建一个文件,填上一些东西就好了。

不知道还会遇见什么问题。

Zacharia2 commented 1 year ago

好像全部都通过了。。。 使用的npm命令,没有使用yarn命令,我重新建的wsl子系统,按照一楼更新的步骤操作的。