supabase-community / nextjs-openai-doc-search

Template for building your own custom ChatGPT style doc search powered by Next.js, OpenAI, and Supabase.
https://supabase.com/blog/chatgpt-supabase-docs
Apache License 2.0
1.59k stars 284 forks source link

Error: Cannot find module 'openai' #31

Closed windhamdavid closed 1 year ago

windhamdavid commented 1 year ago

Bug report

The Deploy to Vercel build comes up with the following error:

const err = new Error(message);
Error: Cannot find module 'openai'
Require stack:
- /vercel/path0/lib/generate-embeddings.ts
at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
at u.default._resolveFilename (/vercel/path0/node_modules/.pnpm/@esbuild-kit+cjs-loader@2.4.2/node_modules/@esbuild-kit/cjs-loader/dist/index.js:1:1519)
at Module._load (node:internal/modules/cjs/loader:920:27)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at updatePageError (/vercel/path0/lib/generate-embeddings.ts:13:8)
at Object.<anonymous> (/vercel/path0/lib/generate-embeddings.ts:493:41)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Object.F (/vercel/path0/node_modules/.pnpm/@esbuild-kit+cjs-loader@2.4.2/node_modules/@esbuild-kit/cjs-loader/dist/index.js:1:941)
at Module.load (node:internal/modules/cjs/loader:1117:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/vercel/path0/lib/generate-embeddings.ts' ]
}
Node.js v18.15.0
ELIFECYCLE  Command failed with exit code 1.

To Fix

Comments

Running build in Cleveland, USA (East) – cle1
--
Cloning github.com/windhamdavid/nextjs-openai-doc-search-starter (Branch: main, Commit: 2b7881b)
Previous build cache not available
Cloning completed: 518.09ms
Running "vercel build"
Vercel CLI 30.2.3
Detected `pnpm-lock.yaml` version 6 generated by pnpm 8...
Installing dependencies...
Lockfile is up to date, resolution step is skipped
Progress: resolved 1, reused 0, downloaded 0, added 0
Packages: +525
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
Content-addressable store is at: /vercel/.local/share/pnpm/store/v3
Virtual store is at:             node_modules/.pnpm
Progress: resolved 525, reused 0, downloaded 57, added 53
Progress: resolved 525, reused 0, downloaded 138, added 133
Progress: resolved 525, reused 0, downloaded 301, added 294
Progress: resolved 525, reused 0, downloaded 411, added 410
Progress: resolved 525, reused 0, downloaded 513, added 507
Progress: resolved 525, reused 0, downloaded 521, added 521
Progress: resolved 525, reused 0, downloaded 523, added 523
Progress: resolved 525, reused 0, downloaded 524, added 523
.../es5-ext@0.10.62/node_modules/es5-ext postinstall$  node -e "try{require('./_postinstall')}catch(e){}" \|\| exit 0
.../node_modules/bufferutil install$ node-gyp-build
.../node_modules/utf-8-validate install$ node-gyp-build
.../es5-ext@0.10.62/node_modules/es5-ext postinstall: Done
.../node_modules/utf-8-validate install: Done
.../node_modules/bufferutil install: Done
.../esbuild@0.17.14/node_modules/esbuild postinstall$ node install.js
Progress: resolved 525, reused 0, downloaded 525, added 525, done
.../esbuild@0.17.14/node_modules/esbuild postinstall: Done
 
dependencies:
+ @radix-ui/react-dialog 1.0.3
+ @radix-ui/react-label 2.0.1
+ @supabase/supabase-js 2.13.0
+ @types/node 18.15.10
+ @types/react 18.0.30
+ @types/react-dom 18.0.11
+ ai 2.1.3
+ class-variance-authority 0.4.0
+ clsx 1.2.1
+ cmdk 0.2.0
+ common-tags 1.8.2
+ eslint 8.36.0
+ eslint-config-next 13.2.4
+ github-slugger 2.0.0
+ gpt3-tokenizer 1.1.5
+ lucide-react 0.128.0
+ mdast 3.0.0
+ mdast-util-from-markdown 1.3.0
+ mdast-util-mdx 2.0.1
+ mdast-util-to-markdown 1.5.0
+ mdast-util-to-string 3.1.1
+ micromark-extension-mdxjs 1.0.0
+ next 13.2.4
+ openai 3.3.0
+ openai-edge 1.1.0
+ react 18.2.0
+ react-dom 18.2.0
+ tailwind-merge 1.10.0
+ tailwindcss-animate 1.0.5
+ typescript 4.9.5
+ unist-builder 3.0.1
+ unist-util-filter 4.0.1
+ yargs 17.7.2
 
devDependencies:
+ @types/common-tags 1.8.1
+ @types/estree 1.0.0
+ @types/mdast 3.0.11
+ @types/yargs 17.0.24
+ autoprefixer 10.4.14
+ dotenv 16.0.3
+ postcss 8.4.21
+ prettier 2.8.7
+ tailwindcss 3.2.7
+ tsx 3.12.6
 
Done in 9.7s
Detected Next.js version: 13.2.4
Running "pnpm run build"
 
> supabase-with-openai@0.1.0 build /vercel/path0
> pnpm run embeddings && next build
 
 
> supabase-with-openai@0.1.0 embeddings /vercel/path0
> tsx lib/generate-embeddings.ts
 
Discovered 1 pages
Checking which pages are new or have changed
[/docs/openai_embeddings] Adding 2 page sections (with embeddings)
Embedding generation complete
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry
 
info  - Linting and checking validity of types...
 
./components/SearchDialog.tsx
39:6  Warning: React Hook React.useEffect has a missing dependency: 'handleModalToggle'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
 
info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
info  - Creating an optimized production build...
<w> [webpack.cache.PackFileCacheStrategy] Serializing big strings (1673kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)
info  - Compiled successfully
info  - Collecting page data...
info  - Generating static pages (0/3)
info  - Generating static pages (3/3)
info  - Finalizing page optimization...
 
Route (pages)                              Size     First Load JS
┌ ○ /                                      30 kB           103 kB
├   └ css/bff950a31bfd5d70.css             1.34 kB
├   /_app                                  0 B            73.5 kB
├ ○ /404                                   182 B          73.7 kB
└ ℇ /api/vector-search                     0 B            73.5 kB
+ First Load JS shared by all              78.1 kB
├ chunks/framework-ac88a2a245aea9ab.js   45.2 kB
├ chunks/main-3c0baa89327dc7f7.js        27 kB
├ chunks/pages/_app-6653cdf85263f45a.js  298 B
├ chunks/webpack-5146130448d8adf7.js     944 B
└ css/0b6a4193ead184fe.css               4.64 kB
 
ℇ  (Streaming)  server-side renders with streaming (uses React 18 SSR streaming or Server Components)
○  (Static)     automatically rendered as static HTML (uses no initial props)
 
Collected static files (public/, static/, .next/static): 3.486ms
Build Completed in /vercel/output [34s]
Deploying outputs...
Deployment completed
Uploading build cache [86.90 MB]...
Build cache uploaded: 2.141s
dongzhenye commented 1 year ago

Thanks, that really works. Note that you should run the pnpm command on your cloned directory, or you won't see any change before git push.

gregnr commented 1 year ago

cc @thorwebdev, I believe this was recently changed to openai-edge to work better with Vercel's ai library.

thorwebdev commented 1 year ago

Thanks @windhamdavid you are correct, that we still use openai as a dependency in the generate embeddings script, thanks for catching and reporting!

windhamdavid commented 1 year ago

happy to help 👊🏼