Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR_MODULE_NOT_FOUND when compiling for Node.js #22

Closed
Quacken8 opened this issue Mar 14, 2024 · 4 comments
Closed

ERR_MODULE_NOT_FOUND when compiling for Node.js #22

Quacken8 opened this issue Mar 14, 2024 · 4 comments
Labels
question Further information is requested

Comments

@Quacken8
Copy link

Quacken8 commented Mar 14, 2024

There is some issue with importing drizzle (possibly related to #1?)
image

I have tried both "moduleResolution": "bundler" and "moduleResolution": "nodenext" as well as

    "paths": {
      "sqlocal/*": ["../node_modules/sqlocal/dist/*"]
    }

I also tried the minimal hello world example from your other repo, however to compile it I had to remove "noEmit": true and "allowImportingTsExtensions": true the problem persists :

➜  sqlocal-drizzle-hello-world git:(main) ✗ node src/main.js 

node:internal/modules/esm/resolve:264
    throw new ERR_MODULE_NOT_FOUND(
          ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/ondra/Documents/sqlocal-drizzle-hello-world/node_modules/.pnpm/sqlocal@0.5.2/node_modules/sqlocal/dist/drizzle/client' imported from /home/ondra/Documents/sqlocal-drizzle-hello-world/node_modules/.pnpm/sqlocal@0.5.2/node_modules/sqlocal/dist/drizzle/index.js
    at finalizeResolution (node:internal/modules/esm/resolve:264:11)
    at moduleResolve (node:internal/modules/esm/resolve:917:10)
    at defaultResolve (node:internal/modules/esm/resolve:1130:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
    at link (node:internal/modules/esm/module_job:84:36) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///home/ondra/Documents/sqlocal-drizzle-hello-world/node_modules/.pnpm/sqlocal@0.5.2/node_modules/sqlocal/dist/drizzle/client'
}

Node.js v20.11.1
@Quacken8
Copy link
Author

Vite does let me build the project, however I'd love to use SQLocal in projects that use fs and other node modules that cannot be built for the browser

@DallasHoff
Copy link
Owner

Am I correct in understanding that you are trying to run SQLocal in Node.js? SQLocal is for running a SQLite database in the browser. It does not work on the server side.

@Quacken8
Copy link
Author

I'm trying to use sqlite in a vscode extension and those run in node. Most sqlite solutions use native modules which may create issues with compatibility and since sqlocal builds to wasm I hoped it would be a better option

@DallasHoff
Copy link
Owner

SQLite WASM does not support Node.js since its storage mechanism is implemented with the Origin Private File System API, which is not supported by Node.js. I think SQLite WASM may be working on a second storage implementation with Node.js support, but for now, it's a browser-only solution.

Depending on what your VSCode extension is meant to do, you may still be able to use SQLocal as long as you do it in a context where the code is being run by VSCode's Chromium engine, not Node.js, such as in a webview.

@DallasHoff DallasHoff changed the title Cannot import sqlocal/drizzle ERR_MODULE_NOT_FOUND when compiling for Node.js Mar 18, 2024
@DallasHoff DallasHoff added the question Further information is requested label Mar 18, 2024
@DallasHoff DallasHoff closed this as not planned Won't fix, can't repro, duplicate, stale Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants