Hello there, so I am new at developing obsidian plugins and I face an error trying to enable mine. (Be ready for a lot of newby questions).
Context and problem
I want to contribute to the obdisidian-annotator plugin. Since I never contributed to obsidian plugins before I followed the build a plugin tutorial and it works just fine.
So then I forked and cloned the annotator plugin into my .obsidian\plugins
, ran npm install
and npm run dev
. No errors just a warning about a circular dependency. But when I open my test vault and try to enable it, it does not work and there is a pop up with “failed to load plugin obsidian-annotator”.
Following this post I tried to debug. When opening the console with ctrl-shift-i
I see this error:
app.js:1 Plugin failure: obsidian-annotator TypeError: Cannot read properties of undefined (reading 'split')
at anonymous (VM323 plugin:obsidian-annotator:22:407134)
at e.<anonymous> (app.js:1:2267896)
at app.js:1:239667
at Object.next (app.js:1:239772)
at a (app.js:1:238490)
In the source code it refers to the line , [O1,U1] = Jq.versions.node.split(".").map((e => Number(e)));
and yes Jq.versions
has no attribute node
.
What I understood about plugin development and my problem
I am not familiar with react development (I just had one class un Uni) and even less with obsidian plugins. But i understood that when I run npm run dev
it creates a main.js
file and that it is this file that is used by obsidian. So this is this file that I can see in the inspector of obsidian and not my files.
I have seen that I can see my code in the inspector if I run app.plugins.plugins["[Plugin ID]"].constructor
in the console but my app.plugins.plugins
only contains the sample plugin and not the annotator plugin that I can’t enable. Will I see my plugin in here once enabled or am I already supposed to see it ?
I tried to debug from VSCode but it never triggers my breakpoints.
My problem here is that I can’t even understand where is my problem since I fail to debug. I think that this problem might come from a dependency since this project has not been updated since a year or so but I’m not even sure about that.
My environment
Obsidian 1.8.9
Node 18.20.4
NPM 10.7.0
Yarn 1.22.22
React 19.0.0
So do you have any tips on how to develop / debug an obsidian plugin ? I’ll take anything.
I am sorry if I just missed something in the documentation but I can’t find any post about problems for enabling plugins.