question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vite not loading the SDK

See original GitHub issue
  • SDK version: 0.2.1
  • OS: MacOS 12.4
  • Node version: 16.16.0 LTS (also tested with 16.6.0)
  • Package manager: Yarn 1.22.19 (also tested with NPM)

So I installed PocketBase and wanted to create a little web to test the tool. I’m a Vue developer so I went ahead and create a new project with the official Vue tool (yarn create vue).

I installed the PocketBase NodeJS package and cross-fetch since I was in NodeJS 16.16.0. Created a little script to list the handmade collections that I created via the Admin UI and It refuses to even been imported to the project.

My code in Vue:

<script setup lang="ts">
import 'cross-fetch/polyfill'
import PocketBase from 'pocketbase'

const client = new PocketBase('http://localhost:8090')
const record = await client.Records.getList('demo')

console.log(record)

</script>

<template>
  <main>
    <h1>Hello Vue + PocketBase!</h1>
  </main>
</template>

I get this error when the dev server start:

$ vite

  vite v2.9.14 dev server running at:

  > Local: http://localhost:3000/
  > Network: use `--host` to expose

  ready in 161ms.

✘ [ERROR] Do not know how to load path: pocketbase

19:32:31 [vite] error while updating dependencies:
Error: Build failed with 1 error:
error: Do not know how to load path: pocketbase
    at failureErrorWithLog (/Users/alejandropp/dev/chatty/node_modules/esbuild/lib/main.js:1605:15)
    at /Users/alejandropp/dev/chatty/node_modules/esbuild/lib/main.js:1251:28
    at runOnEndCallbacks (/Users/alejandropp/dev/chatty/node_modules/esbuild/lib/main.js:1034:63)
    at buildResponseToResult (/Users/alejandropp/dev/chatty/node_modules/esbuild/lib/main.js:1249:7)
    at /Users/alejandropp/dev/chatty/node_modules/esbuild/lib/main.js:1358:14
    at /Users/alejandropp/dev/chatty/node_modules/esbuild/lib/main.js:666:9
    at handleIncomingPacket (/Users/alejandropp/dev/chatty/node_modules/esbuild/lib/main.js:763:9)
    at Socket.readFromStdout (/Users/alejandropp/dev/chatty/node_modules/esbuild/lib/main.js:632:7)
    at Socket.emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:315:12)

So I made sure that the PocketBase SDK was install, and yes, It’s present in the node_modules folder and VS Code Intellisense correctly opens the SDK’s folder when I search for the import’s origin.

I’m a junior developer and I have no idea what could be happening. But by the error log, I suppose that I related to Vite and ESBuild module resolution. Hope this helps to improve the SDK, PocketBase seems like a great product!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alejandroperezpujantecommented, Jul 16, 2022

Well, this is awkward.

Everything seems to be working now. I missed something for sure. Thanks a lot and sorry for wasting your time in this little thing 😅

0reactions
ganigeorgievcommented, Aug 10, 2022

@ByScripts I guess this depends on what load transformers are enabled but yes, some bundlers allow importing local files.

I’ve just tried it and I wasn’t able to reproduce it directly (default sveltekit with vite3) but if I add a path delimiter to the import statement (eg. /pocketbase or ./pocketbase) it will indeed will try to load the binary from the file system.

Anyway, thank you for letting me know. If other users happened to stumble on the same thing, I may consider mentioning it somewhere in the readme.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting - Vite
Vite cannot handle and does not support code that only runs on non-strict mode (sloppy mode). This is because Vite uses ESM and...
Read more >
Unable to build or serve application that imports @aws/sdk ...
Describe the bug I'm trying to migrate React application from CRA to Vite, but experience errors serving and building application.
Read more >
Vue 3 with Vite and Meeting SDK not working
Working in the HelloWord.vue component I'm trying to add the zoom meetings sdk. First step is adding the zoom meeting module using npm...
Read more >
API call not reaching Vite proxy target (localhost:5000)
So I'm trying to learn Vue and I've set up a project and a json-server backend, both running with Docker. Almost everything is...
Read more >
JS SDK + Vite: Realtime Database not working - JavaScript
I tried to replicate the example app for a movies list in Vite + Vue The expample code: Real-Time Database ... JS SDK...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found