nico-martin / ask-my-pdf

A Webapp that uses Retrieval Augmented Generation (RAG) and Large Language Models to interact with a PDF directly in the browser.
https://pdf.nico.dev
MIT License
47 stars 4 forks source link

build error: [vite-plugin-pwa:build] Failed to resolve entry for package "fs". #3

Open waldenn opened 1 month ago

waldenn commented 1 month ago

I tried to fix it with: "import fs from 'node:fs';" in "vite.config.ts", but it did not help. Any ideas how to fix this? Thanks!


`$ npm run build

ask-my-pdf@0.2.1 build tsc && vite build

plugin 'html-plugin' uses deprecated 'enforce' option. Use 'order' option instead. plugin 'html-plugin' uses deprecated 'transform' option. Use 'handler' option instead. vite v5.2.11 building for production... [plugin:vite:resolve] [plugin vite:resolve] Module "crypto" has been externalized for browser compatibility, imported by "/home/foo/dev/ask-my-pdf/node_modules/@nico-martin/tvmjs/lib/index.js". See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. [plugin:vite:resolve] [plugin vite:resolve] Module "perf_hooks" has been externalized for browser compatibility, imported by "/home/foo/dev/ask-my-pdf/node_modules/@nico-martin/tvmjs/lib/index.js". See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. ✓ 79 modules transformed. x Build failed in 1.31s error during build: Error: [vite-plugin-pwa:build] Failed to resolve entry for package "fs". The package may have incorrect main/module/exports specified in its package.json. file: /home/foo/dev/ask-my-pdf/src/store/llm/LlmContextProvider.tsx at packageEntryFailure (file:///home/foo/dev/ask-my-pdf/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:48264:17) at resolvePackageEntry (file:///home/foo/dev/ask-my-pdf/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:48261:5) at tryNodeResolve (file:///home/foo/dev/ask-my-pdf/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:48031:20) at Object.resolveId (file:///home/foo/dev/ask-my-pdf/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:47781:28) at file:///home/foo/dev/ask-my-pdf/node_modules/rollup/dist/es/shared/node-entry.js:19778:40 at async PluginDriver.hookFirstAndGetPlugin (file:///home/foo/dev/ask-my-pdf/node_modules/rollup/dist/es/shared/node-entry.js:19678:28) at async resolveId (file:///home/foo/dev/ask-my-pdf/node_modules/rollup/dist/es/shared/node-entry.js:18359:26) at async ModuleLoader.resolveId (file:///home/foo/dev/ask-my-pdf/node_modules/rollup/dist/es/shared/node-entry.js:18762:15) at async file:///home/foo/dev/ask-my-pdf/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:8444:16 at async Promise.all (index 0) `

nico-martin commented 1 month ago

Hi @waldenn, thanks for reaching out! What OS and what version of Node are you using?

waldenn commented 1 month ago

Hi @waldenn, thanks for reaching out! What OS and what version of Node are you using?

$ node -v v20.14.0

$ cat lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=22.04 DISTRIB_CODENAME=jammy DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"

$ uname -a Linux yoga 6.5.0-41-generic #41~22.04.2-Ubuntu SMP PREEMPT_DYNAMIC Mon Jun 3 11:32:55 UTC 2 x86_64 x86_64 x86_64 GNU/Linux