Hello, I’d like to play with the dataview API on external dev env, but right from the start there appears to be a problem with the installation.
I did npm install -D obsidian-dataview
.
But a simple code like
import { getAPI } from “obsidian-dataview”;
console.log(“test”)
I get the error Error: Cannot find module 'obsidian'
. However, the module seems to be installed.
Maybe nothing direct related to your problem, but when I see something like that, those are my steps (and often is .env related):
-
Check Installation:
- Run
npm install ...
(or yarn add ...
) to ensure the module is installed in your node_modules
folder.
-
Verify Import Path:
-
TypeScript Configuration:
-
Check Your Workspace:
- If you’re working on a plugin, ensure that you have the Obsidian Plugin API set up correctly. Sometimes, the
obsidian
module is available only in the actual Obsidian environment, rather than a standalone Node.js project.
This is a copy/paste from my checklist … hope helps!
Cheers, Marko