BBazard / obsidian-orgmode-cm6

Orgmode plugin for Obsidian
MIT License
17 stars 0 forks source link

npm install fails with TS2307: Cannot find module './orgmode.grammar' or its corresponding type declarations. #1

Closed cpbotha closed 1 month ago

cpbotha commented 2 months ago

Thank you very much for making this!

I would like to build according to the instructions in the readme. However, after following all instructions, npm install fails as follows:

obsidian-orgmode-cm6 % npm install

> prepare
> lezer-generator --typeScript codemirror-lang-orgmode/src/orgmode.grammar -o codemirror-lang-orgmode/src/parser && rollup -c

Wrote codemirror-lang-orgmode/src/parser.ts and codemirror-lang-orgmode/src/parser.terms.ts

codemirror-lang-orgmode/src/index.ts → codemirror-lang-orgmode/dist/index.cjs, ./codemirror-lang-orgmode/dist...
[!] (plugin Typescript) TS2307: Cannot find module './orgmode.grammar' or its corresponding type declarations.
codemirror-lang-orgmode/src/index.ts (1:24)

1 import { parser } from "./orgmode.grammar"
                         ~~~~~~~~~~~~~~~~~~~

npm ERR! code 1
npm ERR! path /Users/charlbotha/build/obsidian-orgmode-cm6
npm ERR! command failed
npm ERR! command sh -c lezer-generator --typeScript codemirror-lang-orgmode/src/orgmode.grammar -o codemirror-lang-orgmode/src/parser && rollup -c

This is with node 20.11.1 and npm 10.2.4.

I also tried replacing that orgmode.grammar include with the auto-generated parser.ts (just in case this could work around the issue), but then ran into:

npm install

> prepare
> lezer-generator --typeScript codemirror-lang-orgmode/src/orgmode.grammar -o codemirror-lang-orgmode/src/parser && rollup -c

Wrote codemirror-lang-orgmode/src/parser.ts and codemirror-lang-orgmode/src/parser.terms.ts

codemirror-lang-orgmode/src/index.ts → codemirror-lang-orgmode/dist/index.cjs, ./codemirror-lang-orgmode/dist...
[!] (plugin Typescript) TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.
codemirror-lang-orgmode/src/external-tokens.ts (37:28)

37   const words = [...global.todoKeywords, ...global.doneKeywords]
                              ~~~~~~~~~~~~

npm ERR! code 1
npm ERR! path /Users/charlbotha/build/obsidian-orgmode-cm6
npm ERR! command failed
npm ERR! command sh -c lezer-generator --typeScript codemirror-lang-orgmode/src/orgmode.grammar -o codemirror-lang-orgmode/src/parser && rollup -c
BBazard commented 2 months ago

I am happy you appreciate it!

The obsidian plugin depends on the parser and the parser depends on the obsidian plugin config which makes building the project not as straightforward as it could be. It could be improved but I am spending my efforts on some other features currently.

Thank you for the detailed issue, please let me know if my pull request fixed the problem.

cpbotha commented 1 month ago

Thank you very much, I am now able to build and install as per the instructions in the README!