Closed centminmod closed 1 year ago
Not sure what this means but related to https://github.com/cloudflare/next-on-pages#2-configure-the-application-to-use-the-edge-runtime ?
In order for your application to run on Cloudflare Pages, it needs to be set to use the Edge Runtime. Make sure that all the files in your application containing server-side code (e.g. any API Routes and any pages which use getServerSideProps) export a config object specifying the use of the Edge Runtime:
export const config = {
runtime: 'edge',
};
Additionally, ensure that your application is not using any unsupported APIs and that its API routes are defined as Edge API Routes.
so i need to change your next.conf.js from
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
env: {
// defaults to TRUE, unless API Keys are set at build time; this flag is used by the UI
REQUIRE_USER_API_KEYS: !process.env.OPENAI_API_KEY,
},
webpack(config, { isServer, dev }) {
// @mui/joy: anything material gets redirected to Joy
config.resolve.alias['@mui/material'] = '@mui/joy';
// @dqbd/tiktoken: enable asynchronous WebAssembly
config.experiments = {
asyncWebAssembly: true,
layers: true,
};
return config;
},
};
module.exports = nextConfig;
to
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
env: {
// defaults to TRUE, unless API Keys are set at build time; this flag is used by the UI
REQUIRE_USER_API_KEYS: !process.env.OPENAI_API_KEY,
},
experimental: {
runtime: 'edge',
},
webpack(config, { isServer, dev }) {
// @mui/joy: anything material gets redirected to Joy
config.resolve.alias['@mui/material'] = '@mui/joy';
// @dqbd/tiktoken: enable asynchronous WebAssembly
config.experiments = {
asyncWebAssembly: true,
layers: true,
};
return config;
},
};
module.exports = nextConfig;
?
However, tried the change but now get
2023-04-10T21:33:56.784279Z Cloning repository...
2023-04-10T21:33:57.847026Z From https://github.com/centminmod/nextjs-chatgpt-app
2023-04-10T21:33:57.847807Z * branch b20eac9b8cb8eb1415958962eed68713538a0a48 -> FETCH_HEAD
2023-04-10T21:33:57.848011Z
2023-04-10T21:33:57.944992Z HEAD is now at b20eac9 Merge branch 'main' of https://github.com/centminmod/nextjs-chatgpt-app into main
2023-04-10T21:33:57.945881Z
2023-04-10T21:33:58.110599Z
2023-04-10T21:33:58.149495Z Success: Finished cloning repository files
2023-04-10T21:33:58.843183Z Installing dependencies
2023-04-10T21:33:58.855202Z Python version set to 3.7
2023-04-10T21:34:03.071733Z Downloading and installing node v17.9.1...
2023-04-10T21:34:03.45893Z Downloading https://nodejs.org/dist/v17.9.1/node-v17.9.1-linux-x64.tar.xz...
2023-04-10T21:34:03.805781Z Computing checksum with sha256sum
2023-04-10T21:34:03.943642Z Checksums matched!
2023-04-10T21:34:09.266518Z Now using node v17.9.1 (npm v8.11.0)
2023-04-10T21:34:09.718374Z Started restoring cached build plugins
2023-04-10T21:34:09.73571Z Finished restoring cached build plugins
2023-04-10T21:34:10.335758Z Attempting ruby version 2.7.1, read from environment
2023-04-10T21:34:12.62803Z Using /opt/buildhome/.rvm/gems/ruby-2.7.1
2023-04-10T21:34:13.776276Z Using PHP version 7.4
2023-04-10T21:34:13.942536Z 5.2.5 is already installed.
2023-04-10T21:34:13.972997Z Using Swift version 5.2.5
2023-04-10T21:34:13.974212Z Started restoring cached node modules
2023-04-10T21:34:13.992008Z Finished restoring cached node modules
2023-04-10T21:34:14.516113Z Installing NPM modules using NPM version 8.11.0
2023-04-10T21:34:15.862011Z npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
2023-04-10T21:34:15.862336Z npm WARN config location in the cache, and they are managed by
2023-04-10T21:34:15.862693Z npm WARN config [`cacache`](http://npm.im/cacache).
2023-04-10T21:34:16.284771Z npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
2023-04-10T21:34:16.286337Z npm WARN config location in the cache, and they are managed by
2023-04-10T21:34:16.286579Z npm WARN config [`cacache`](http://npm.im/cacache).
2023-04-10T21:34:44.80024Z
2023-04-10T21:34:44.800689Z added 492 packages, and audited 493 packages in 29s
2023-04-10T21:34:44.800889Z
2023-04-10T21:34:44.80103Z 190 packages are looking for funding
2023-04-10T21:34:44.801162Z run `npm fund` for details
2023-04-10T21:34:44.802408Z
2023-04-10T21:34:44.802702Z found 0 vulnerabilities
2023-04-10T21:34:44.822912Z NPM modules installed
2023-04-10T21:34:44.895553Z Installing Hugo 0.54.0
2023-04-10T21:34:45.627524Z Hugo Static Site Generator v0.54.0-B1A82C61A/extended linux/amd64 BuildDate: 2019-02-01T10:04:38Z
2023-04-10T21:34:45.630471Z Started restoring cached go cache
2023-04-10T21:34:45.654418Z Finished restoring cached go cache
2023-04-10T21:34:45.654845Z Installing Go version 1.16
2023-04-10T21:34:55.055448Z
2023-04-10T21:34:55.076626Z unset GOOS;
2023-04-10T21:34:55.09123Z unset GOARCH;
2023-04-10T21:34:55.091596Z export GOROOT='/opt/buildhome/.gimme_cache/versions/go1.16.linux.amd64';
2023-04-10T21:34:55.091802Z export PATH="/opt/buildhome/.gimme_cache/versions/go1.16.linux.amd64/bin:${PATH}";
2023-04-10T21:34:55.091979Z go version >&2;
2023-04-10T21:34:55.092112Z
2023-04-10T21:34:55.097479Z export GIMME_ENV="/opt/buildhome/.gimme_cache/env/go1.16.linux.amd64.env"
2023-04-10T21:34:55.112152Z go version go1.16 linux/amd64
2023-04-10T21:34:55.116436Z Installing missing commands
2023-04-10T21:34:55.116936Z Verify run directory
2023-04-10T21:34:55.117162Z Executing user command: npx @cloudflare/next-on-pages --experimental-minify
2023-04-10T21:34:55.651986Z npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
2023-04-10T21:34:55.652351Z npm WARN config location in the cache, and they are managed by
2023-04-10T21:34:55.652559Z npm WARN config [`cacache`](http://npm.im/cacache).
2023-04-10T21:34:56.304086Z npm WARN exec The following package was not found and will be installed: @cloudflare/next-on-pages
2023-04-10T21:35:11.686289Z npm WARN deprecated rollup-plugin-inject@3.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
2023-04-10T21:35:11.855309Z npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
2023-04-10T21:35:13.147367Z npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
2023-04-10T21:35:21.017507Z ⚡️ @cloudflare/next-on-pages CLI v.0.7.0
2023-04-10T21:35:21.020316Z ⚡️ Detected Package Manager: npm
2023-04-10T21:35:21.020625Z ⚡️ Preparing project...
2023-04-10T21:35:21.022775Z ⚡️ Project is ready
2023-04-10T21:35:21.023078Z ⚡️ Building project...
2023-04-10T21:35:21.541689Z ▲ npm
2023-04-10T21:35:21.542899Z ▲ WARN config tmp This setting is no longer used. npm stores temporary files in a special
2023-04-10T21:35:21.543185Z ▲ npm WARN config location in the cache, and they are managed by
2023-04-10T21:35:21.543333Z ▲ npm WARN config [`cacache`](http://npm.im/cacache).
2023-04-10T21:35:22.209757Z ▲ npm
2023-04-10T21:35:22.210184Z ▲ WARN
2023-04-10T21:35:22.210786Z ▲ exec The following package was not found and will be installed: vercel
2023-04-10T21:35:29.897466Z ▲ npm WARN
2023-04-10T21:35:29.89813Z ▲ deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
2023-04-10T21:35:30.207596Z ▲ npm
2023-04-10T21:35:30.208113Z ▲ WARN deprecated rollup-plugin-inject@3.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
2023-04-10T21:35:30.415705Z ▲ npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
2023-04-10T21:35:34.908372Z ▲ Vercel CLI 28.18.4
2023-04-10T21:35:35.217036Z ▲ Installing dependencies...
2023-04-10T21:35:35.737856Z ▲ npm
2023-04-10T21:35:35.739154Z ▲ WARN config tmp This setting is no longer used. npm stores temporary files in a special
2023-04-10T21:35:35.739548Z ▲ npm WARN
2023-04-10T21:35:35.739825Z ▲ config location in the cache, and they are managed by
2023-04-10T21:35:35.740058Z ▲ npm
2023-04-10T21:35:35.740292Z ▲ WARN config
2023-04-10T21:35:35.740508Z ▲ [`cacache`](http://npm.im/cacache).
2023-04-10T21:35:36.461261Z ▲ up to date in 756ms
2023-04-10T21:35:36.461965Z ▲ 190 packages are looking for funding
2023-04-10T21:35:36.462169Z ▲ run `npm fund` for details
2023-04-10T21:35:36.474291Z ▲ Detected Next.js version: 13.3.0
2023-04-10T21:35:36.479371Z ▲ Detected `package-lock.json` generated by npm 7+...
2023-04-10T21:35:36.479807Z ▲ Running "npm run build"
2023-04-10T21:35:36.994581Z ▲ npm
2023-04-10T21:35:36.995018Z ▲ WARN config tmp This setting is no longer used. npm stores temporary files in a special
2023-04-10T21:35:36.995233Z ▲ npm WARN
2023-04-10T21:35:36.995789Z ▲ config location in the cache, and they are managed by
2023-04-10T21:35:36.99618Z ▲ npm WARN config [`cacache`](http://npm.im/cacache).
2023-04-10T21:35:37.013202Z ▲ > nextjs-chatgpt-app@0.2.0 build
2023-04-10T21:35:37.013545Z ▲ > next build
2023-04-10T21:35:37.602821Z ▲ warn - You have enabled experimental feature (runtime) in next.config.js.
2023-04-10T21:35:37.603618Z ▲ warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
2023-04-10T21:35:37.757394Z ▲ info - Linting and checking validity of types...
2023-04-10T21:35:46.413006Z ▲ info - Creating an optimized production build...
2023-04-10T21:35:46.889194Z ▲ warn - You are using `experimental.runtime` which was removed. Check https://nextjs.org/docs/api-routes/edge-api-routes on how to use edge runtime.
2023-04-10T21:36:01.980968Z ▲ Failed to compile.
2023-04-10T21:36:01.981444Z ▲ ./node_modules/multipipe/index.js:7:0
2023-04-10T21:36:01.981618Z ▲ Module not found: Can't resolve 'stream'
2023-04-10T21:36:01.981814Z ▲
2023-04-10T21:36:01.981979Z ▲ https://nextjs.org/docs/messages/module-not-found
2023-04-10T21:36:01.982096Z ▲
2023-04-10T21:36:01.982206Z ▲ Import trace for requested module:
2023-04-10T21:36:01.982313Z ▲ ./node_modules/@emotion/server/create-instance/dist/emotion-server-create-instance.browser.esm.js
2023-04-10T21:36:01.982445Z ▲ ./pages/_document.tsx
2023-04-10T21:36:01.982679Z ▲ ./node_modules/next/dist/build/webpack/loaders/next-edge-ssr-loader/index.js?absolute500Path=&absoluteAppPath=private-next-pages%2F_app.tsx&absoluteDocumentPath=private-next-pages%2F_document.tsx&absoluteErrorPath=next%2Fdist%2Fpages%2F_error&absolutePagePath=private-next-pages%2Findex.tsx&buildId=pACNkUCpKtwjMkmYi7v1Z&dev=false&isServerComponent=false&page=%2F&stringifiedConfig=%7B%22env%22%3A%7B%22REQUIRE_USER_API_KEYS%22%3Atrue%7D%2C%22eslint%22%3A%7B%22ignoreDuringBuilds%22%3Afalse%7D%2C%22typescript%22%3A%7B%22ignoreBuildErrors%22%3Afalse%2C%22tsconfigPath%22%3A%22tsconfig.json%22%7D%2C%22distDir%22%3A%22.next%22%2C%22cleanDistDir%22%3Atrue%2C%22assetPrefix%22%3A%22%22%2C%22configOrigin%22%3A%22next.config.js%22%2C%22useFileSystemPublicRoutes%22%3Atrue%2C%22generateEtags%22%3Atrue%2C%22pageExtensions%22%3A%5B%22tsx%22%2C%22ts%22%2C%22jsx%22%2C%22js%22%5D%2C%22poweredByHeader%22%3Atrue%2C%22compress%22%3Atrue%2C%22analyticsId%22%3A%22%22%2C%22images%22%3A%7B%22deviceSizes%22%3A%5B640%2C750%2C828%2C1080%2C1200%2C1920%2C2048%2C3840%5D%2C%22imageSizes%22%3A%5B16%2C32%2C48%2C64%2C96%2C128%2C256%2C384%5D%2C%22path%22%3A%22%2F_next%2Fimage%22%2C%22loader%22%3A%22default%22%2C%22loaderFile%22%3A%22%22%2C%22domains%22%3A%5B%5D%2C%22disableStaticImages%22%3Afalse%2C%22minimumCacheTTL%22%3A60%2C%22formats%22%3A%5B%22image%2Fwebp%22%5D%2C%22dangerouslyAllowSVG%22%3Afalse%2C%22contentSecurityPolicy%22%3A%22script-src%20'none'%3B%20frame-src%20'none'%3B%20sandbox%3B%22%2C%22contentDispositionType%22%3A%22inline%22%2C%22remotePatterns%22%3A%5B%5D%2C%22unoptimized%22%3Afalse%7D%2C%22devIndicators%22%3A%7B%22buildActivity%22%3Atrue%2C%22buildActivityPosition%22%3A%22bottom-right%22%7D%2C%22onDemandEntries%22%3A%7B%22maxInactiveAge%22%3A15000%2C%22pagesBufferLength%22%3A2%7D%2C%22amp%22%3A%7B%22canonicalBase%22%3A%22%22%7D%2C%22basePath%22%3A%22%22%2C%22sassOptions%22%3A%7B%7D%2C%22trailingSlash%22%3Afalse%2C%22i18n%22%3Anull%2C%22productionBrowserSourceMaps%22%3Afalse%2C%22optimizeFonts%22%3Atrue%2C%22excludeDefaultMomentLocales%22%3Atrue%2C%22serverRuntimeConfig%22%3A%7B%7D%2C%22publicRuntimeConfig%22%3A%7B%7D%2C%22reactStrictMode%22%3Atrue%2C%22httpAgentOptions%22%3A%7B%22keepAlive%22%3Atrue%7D%2C%22outputFileTracing%22%3Atrue%2C%22staticPageGenerationTimeout%22%3A60%2C%22swcMinify%22%3Atrue%2C%22experimental%22%3A%7B%22clientRouterFilter%22%3Afalse%2C%22clientRouterFilterRedirects%22%3Afalse%2C%22fetchCacheKeyPrefix%22%3A%22%22%2C%22middlewarePrefetch%22%3A%22flexible%22%2C%22optimisticClientCache%22%3Atrue%2C%22runtime%22%3A%22edge%22%2C%22manualClientBasePath%22%3Afalse%2C%22legacyBrowsers%22%3Afalse%2C%22newNextLinkBehavior%22%3Atrue%2C%22cpus%22%3A3%2C%22sharedPool%22%3Atrue%2C%22isrFlushToDisk%22%3Atrue%2C%22workerThreads%22%3Afalse%2C%22pageEnv%22%3Afalse%2C%22optimizeCss%22%3Afalse%2C%22nextScriptWorkers%22%3Afalse%2C%22scrollRestoration%22%3Afalse%2C%22externalDir%22%3Afalse%2C%22disableOptimizedLoading%22%3Afalse%2C%22gzipSize%22%3Atrue%2C%22swcFileReading%22%3Atrue%2C%22craCompat%22%3Afalse%2C%22esmExternals%22%3Atrue%2C%22appDir%22%3Afalse%2C%22isrMemoryCacheSize%22%3A52428800%2C%22fullySpecified%22%3Afalse%2C%22outputFileTracingRoot%22%3A%22%2Fopt%2Fbuildhome%2Frepo%22%2C%22swcTraceProfiling%22%3Afalse%2C%22forceSwcTransforms%22%3Afalse%2C%22largePageDataBytes%22%3A128000%2C%22enableUndici%22%3Afalse%2C%22adjustFontFallbacks%22%3Afalse%2C%22adjustFontFallbacksWithSizeAdjust%22%3Afalse%2C%22typedRoutes%22%3Afalse%2C%22instrumentationHook%22%3Afalse%7D%2C%22configFile%22%3A%22%2Fopt%2Fbuildhome%2Frepo%2Fnext.config.js%22%2C%22configFileName%22%3A%22next.config.js%22%7D&pagesType=pages&appDirLoader=&sriEnabled=false&incrementalCacheHandlerPath=!
2023-04-10T21:36:01.9829Z ▲
2023-04-10T21:36:01.983061Z ▲ ./node_modules/readable-stream/lib/_stream_readable.js:43:0
2023-04-10T21:36:01.983207Z ▲ Module not found: Can't resolve 'stream'
2023-04-10T21:36:01.983348Z ▲
2023-04-10T21:36:01.98346Z ▲ https://nextjs.org/docs/messages/module-not-found
2023-04-10T21:36:01.98357Z ▲
2023-04-10T21:36:01.983678Z ▲ Import trace for requested module:
2023-04-10T21:36:01.983785Z ▲ ./node_modules/readable-stream/readable.js
2023-04-10T21:36:01.983912Z ▲ ./node_modules/html-tokenize/index.js
2023-04-10T21:36:01.984026Z ▲ ./node_modules/@emotion/server/create-instance/dist/emotion-server-create-instance.browser.esm.js
2023-04-10T21:36:01.984144Z ▲ ./pages/_document.tsx
2023-04-10T21:36:01.984264Z ▲ ./node_modules/next/dist/build/webpack/loaders/next-edge-ssr-loader/index.js?absolute500Path=&absoluteAppPath=private-next-pages%2F_app.tsx&absoluteDocumentPath=private-next-pages%2F_document.tsx&absoluteErrorPath=next%2Fdist%2Fpages%2F_error&absolutePagePath=private-next-pages%2Findex.tsx&buildId=pACNkUCpKtwjMkmYi7v1Z&dev=false&isServerComponent=false&page=%2F&stringifiedConfig=%7B%22env%22%3A%7B%22REQUIRE_USER_API_KEYS%22%3Atrue%7D%2C%22eslint%22%3A%7B%22ignoreDuringBuilds%22%3Afalse%7D%2C%22typescript%22%3A%7B%22ignoreBuildErrors%22%3Afalse%2C%22tsconfigPath%22%3A%22tsconfig.json%22%7D%2C%22distDir%22%3A%22.next%22%2C%22cleanDistDir%22%3Atrue%2C%22assetPrefix%22%3A%22%22%2C%22configOrigin%22%3A%22next.config.js%22%2C%22useFileSystemPublicRoutes%22%3Atrue%2C%22generateEtags%22%3Atrue%2C%22pageExtensions%22%3A%5B%22tsx%22%2C%22ts%22%2C%22jsx%22%2C%22js%22%5D%2C%22poweredByHeader%22%3Atrue%2C%22compress%22%3Atrue%2C%22analyticsId%22%3A%22%22%2C%22images%22%3A%7B%22deviceSizes%22%3A%5B640%2C750%2C828%2C1080%2C1200%2C1920%2C2048%2C3840%5D%2C%22imageSizes%22%3A%5B16%2C32%2C48%2C64%2C96%2C128%2C256%2C384%5D%2C%22path%22%3A%22%2F_next%2Fimage%22%2C%22loader%22%3A%22default%22%2C%22loaderFile%22%3A%22%22%2C%22domains%22%3A%5B%5D%2C%22disableStaticImages%22%3Afalse%2C%22minimumCacheTTL%22%3A60%2C%22formats%22%3A%5B%22image%2Fwebp%22%5D%2C%22dangerouslyAllowSVG%22%3Afalse%2C%22contentSecurityPolicy%22%3A%22script-src%20'none'%3B%20frame-src%20'none'%3B%20sandbox%3B%22%2C%22contentDispositionType%22%3A%22inline%22%2C%22remotePatterns%22%3A%5B%5D%2C%22unoptimized%22%3Afalse%7D%2C%22devIndicators%22%3A%7B%22buildActivity%22%3Atrue%2C%22buildActivityPosition%22%3A%22bottom-right%22%7D%2C%22onDemandEntries%22%3A%7B%22maxInactiveAge%22%3A15000%2C%22pagesBufferLength%22%3A2%7D%2C%22amp%22%3A%7B%22canonicalBase%22%3A%22%22%7D%2C%22basePath%22%3A%22%22%2C%22sassOptions%22%3A%7B%7D%2C%22trailingSlash%22%3Afalse%2C%22i18n%22%3Anull%2C%22productionBrowserSourceMaps%22%3Afalse%2C%22optimizeFonts%22%3Atrue%2C%22excludeDefaultMomentLocales%22%3Atrue%2C%22serverRuntimeConfig%22%3A%7B%7D%2C%22publicRuntimeConfig%22%3A%7B%7D%2C%22reactStrictMode%22%3Atrue%2C%22httpAgentOptions%22%3A%7B%22keepAlive%22%3Atrue%7D%2C%22outputFileTracing%22%3Atrue%2C%22staticPageGenerationTimeout%22%3A60%2C%22swcMinify%22%3Atrue%2C%22experimental%22%3A%7B%22clientRouterFilter%22%3Afalse%2C%22clientRouterFilterRedirects%22%3Afalse%2C%22fetchCacheKeyPrefix%22%3A%22%22%2C%22middlewarePrefetch%22%3A%22flexible%22%2C%22optimisticClientCache%22%3Atrue%2C%22runtime%22%3A%22edge%22%2C%22manualClientBasePath%22%3Afalse%2C%22legacyBrowsers%22%3Afalse%2C%22newNextLinkBehavior%22%3Atrue%2C%22cpus%22%3A3%2C%22sharedPool%22%3Atrue%2C%22isrFlushToDisk%22%3Atrue%2C%22workerThreads%22%3Afalse%2C%22pageEnv%22%3Afalse%2C%22optimizeCss%22%3Afalse%2C%22nextScriptWorkers%22%3Afalse%2C%22scrollRestoration%22%3Afalse%2C%22externalDir%22%3Afalse%2C%22disableOptimizedLoading%22%3Afalse%2C%22gzipSize%22%3Atrue%2C%22swcFileReading%22%3Atrue%2C%22craCompat%22%3Afalse%2C%22esmExternals%22%3Atrue%2C%22appDir%22%3Afalse%2C%22isrMemoryCacheSize%22%3A52428800%2C%22fullySpecified%22%3Afalse%2C%22outputFileTracingRoot%22%3A%22%2Fopt%2Fbuildhome%2Frepo%22%2C%22swcTraceProfiling%22%3Afalse%2C%22forceSwcTransforms%22%3Afalse%2C%22largePageDataBytes%22%3A128000%2C%22enableUndici%22%3Afalse%2C%22adjustFontFallbacks%22%3Afalse%2C%22adjustFontFallbacksWithSizeAdjust%22%3Afalse%2C%22typedRoutes%22%3Afalse%2C%22instrumentationHook%22%3Afalse%7D%2C%22configFile%22%3A%22%2Fopt%2Fbuildhome%2Frepo%2Fnext.config.js%22%2C%22configFileName%22%3A%22next.config.js%22%7D&pagesType=pages&appDirLoader=&sriEnabled=false&incrementalCacheHandlerPath=!
2023-04-10T21:36:01.984421Z ▲
2023-04-10T21:36:01.984549Z ▲ ./node_modules/readable-stream/lib/_stream_writable.js:40:0
2023-04-10T21:36:01.984662Z ▲ Module not found: Can't resolve 'stream'
2023-04-10T21:36:01.984789Z ▲
2023-04-10T21:36:01.984925Z ▲ https://nextjs.org/docs/messages/module-not-found
2023-04-10T21:36:01.985037Z ▲
2023-04-10T21:36:01.985143Z ▲ Import trace for requested module:
2023-04-10T21:36:01.985252Z ▲ ./node_modules/readable-stream/readable.js
2023-04-10T21:36:01.985382Z ▲ ./node_modules/html-tokenize/index.js
2023-04-10T21:36:01.985508Z ▲ ./node_modules/@emotion/server/create-instance/dist/emotion-server-create-instance.browser.esm.js
2023-04-10T21:36:01.985626Z ▲ ./pages/_document.tsx
2023-04-10T21:36:01.985772Z ▲ ./node_modules/next/dist/build/webpack/loaders/next-edge-ssr-loader/index.js?absolute500Path=&absoluteAppPath=private-next-pages%2F_app.tsx&absoluteDocumentPath=private-next-pages%2F_document.tsx&absoluteErrorPath=next%2Fdist%2Fpages%2F_error&absolutePagePath=private-next-pages%2Findex.tsx&buildId=pACNkUCpKtwjMkmYi7v1Z&dev=false&isServerComponent=false&page=%2F&stringifiedConfig=%7B%22env%22%3A%7B%22REQUIRE_USER_API_KEYS%22%3Atrue%7D%2C%22eslint%22%3A%7B%22ignoreDuringBuilds%22%3Afalse%7D%2C%22typescript%22%3A%7B%22ignoreBuildErrors%22%3Afalse%2C%22tsconfigPath%22%3A%22tsconfig.json%22%7D%2C%22distDir%22%3A%22.next%22%2C%22cleanDistDir%22%3Atrue%2C%22assetPrefix%22%3A%22%22%2C%22configOrigin%22%3A%22next.config.js%22%2C%22useFileSystemPublicRoutes%22%3Atrue%2C%22generateEtags%22%3Atrue%2C%22pageExtensions%22%3A%5B%22tsx%22%2C%22ts%22%2C%22jsx%22%2C%22js%22%5D%2C%22poweredByHeader%22%3Atrue%2C%22compress%22%3Atrue%2C%22analyticsId%22%3A%22%22%2C%22images%22%3A%7B%22deviceSizes%22%3A%5B640%2C750%2C828%2C1080%2C1200%2C1920%2C2048%2C3840%5D%2C%22imageSizes%22%3A%5B16%2C32%2C48%2C64%2C96%2C128%2C256%2C384%5D%2C%22path%22%3A%22%2F_next%2Fimage%22%2C%22loader%22%3A%22default%22%2C%22loaderFile%22%3A%22%22%2C%22domains%22%3A%5B%5D%2C%22disableStaticImages%22%3Afalse%2C%22minimumCacheTTL%22%3A60%2C%22formats%22%3A%5B%22image%2Fwebp%22%5D%2C%22dangerouslyAllowSVG%22%3Afalse%2C%22contentSecurityPolicy%22%3A%22script-src%20'none'%3B%20frame-src%20'none'%3B%20sandbox%3B%22%2C%22contentDispositionType%22%3A%22inline%22%2C%22remotePatterns%22%3A%5B%5D%2C%22unoptimized%22%3Afalse%7D%2C%22devIndicators%22%3A%7B%22buildActivity%22%3Atrue%2C%22buildActivityPosition%22%3A%22bottom-right%22%7D%2C%22onDemandEntries%22%3A%7B%22maxInactiveAge%22%3A15000%2C%22pagesBufferLength%22%3A2%7D%2C%22amp%22%3A%7B%22canonicalBase%22%3A%22%22%7D%2C%22basePath%22%3A%22%22%2C%22sassOptions%22%3A%7B%7D%2C%22trailingSlash%22%3Afalse%2C%22i18n%22%3Anull%2C%22productionBrowserSourceMaps%22%3Afalse%2C%22optimizeFonts%22%3Atrue%2C%22excludeDefaultMomentLocales%22%3Atrue%2C%22serverRuntimeConfig%22%3A%7B%7D%2C%22publicRuntimeConfig%22%3A%7B%7D%2C%22reactStrictMode%22%3Atrue%2C%22httpAgentOptions%22%3A%7B%22keepAlive%22%3Atrue%7D%2C%22outputFileTracing%22%3Atrue%2C%22staticPageGenerationTimeout%22%3A60%2C%22swcMinify%22%3Atrue%2C%22experimental%22%3A%7B%22clientRouterFilter%22%3Afalse%2C%22clientRouterFilterRedirects%22%3Afalse%2C%22fetchCacheKeyPrefix%22%3A%22%22%2C%22middlewarePrefetch%22%3A%22flexible%22%2C%22optimisticClientCache%22%3Atrue%2C%22runtime%22%3A%22edge%22%2C%22manualClientBasePath%22%3Afalse%2C%22legacyBrowsers%22%3Afalse%2C%22newNextLinkBehavior%22%3Atrue%2C%22cpus%22%3A3%2C%22sharedPool%22%3Atrue%2C%22isrFlushToDisk%22%3Atrue%2C%22workerThreads%22%3Afalse%2C%22pageEnv%22%3Afalse%2C%22optimizeCss%22%3Afalse%2C%22nextScriptWorkers%22%3Afalse%2C%22scrollRestoration%22%3Afalse%2C%22externalDir%22%3Afalse%2C%22disableOptimizedLoading%22%3Afalse%2C%22gzipSize%22%3Atrue%2C%22swcFileReading%22%3Atrue%2C%22craCompat%22%3Afalse%2C%22esmExternals%22%3Atrue%2C%22appDir%22%3Afalse%2C%22isrMemoryCacheSize%22%3A52428800%2C%22fullySpecified%22%3Afalse%2C%22outputFileTracingRoot%22%3A%22%2Fopt%2Fbuildhome%2Frepo%22%2C%22swcTraceProfiling%22%3Afalse%2C%22forceSwcTransforms%22%3Afalse%2C%22largePageDataBytes%22%3A128000%2C%22enableUndici%22%3Afalse%2C%22adjustFontFallbacks%22%3Afalse%2C%22adjustFontFallbacksWithSizeAdjust%22%3Afalse%2C%22typedRoutes%22%3Afalse%2C%22instrumentationHook%22%3Afalse%7D%2C%22configFile%22%3A%22%2Fopt%2Fbuildhome%2Frepo%2Fnext.config.js%22%2C%22configFileName%22%3A%22next.config.js%22%7D&pagesType=pages&appDirLoader=&sriEnabled=false&incrementalCacheHandlerPath=!
2023-04-10T21:36:01.98594Z ▲
2023-04-10T21:36:01.986057Z ▲ ./node_modules/readable-stream/readable.js:1:0
2023-04-10T21:36:01.986177Z ▲ Module not found: Can't resolve 'stream'
2023-04-10T21:36:01.986283Z ▲
2023-04-10T21:36:01.986389Z ▲ https://nextjs.org/docs/messages/module-not-found
2023-04-10T21:36:01.986492Z ▲
2023-04-10T21:36:01.986597Z ▲ Import trace for requested module:
2023-04-10T21:36:01.986702Z ▲ ./node_modules/html-tokenize/index.js
2023-04-10T21:36:01.986817Z ▲ ./node_modules/@emotion/server/create-instance/dist/emotion-server-create-instance.browser.esm.js
2023-04-10T21:36:01.986956Z ▲ ./pages/_document.tsx
2023-04-10T21:36:01.987084Z ▲ ./node_modules/next/dist/build/webpack/loaders/next-edge-ssr-loader/index.js?absolute500Path=&absoluteAppPath=private-next-pages%2F_app.tsx&absoluteDocumentPath=private-next-pages%2F_document.tsx&absoluteErrorPath=next%2Fdist%2Fpages%2F_error&absolutePagePath=private-next-pages%2Findex.tsx&buildId=pACNkUCpKtwjMkmYi7v1Z&dev=false&isServerComponent=false&page=%2F&stringifiedConfig=%7B%22env%22%3A%7B%22REQUIRE_USER_API_KEYS%22%3Atrue%7D%2C%22eslint%22%3A%7B%22ignoreDuringBuilds%22%3Afalse%7D%2C%22typescript%22%3A%7B%22ignoreBuildErrors%22%3Afalse%2C%22tsconfigPath%22%3A%22tsconfig.json%22%7D%2C%22distDir%22%3A%22.next%22%2C%22cleanDistDir%22%3Atrue%2C%22assetPrefix%22%3A%22%22%2C%22configOrigin%22%3A%22next.config.js%22%2C%22useFileSystemPublicRoutes%22%3Atrue%2C%22generateEtags%22%3Atrue%2C%22pageExtensions%22%3A%5B%22tsx%22%2C%22ts%22%2C%22jsx%22%2C%22js%22%5D%2C%22poweredByHeader%22%3Atrue%2C%22compress%22%3Atrue%2C%22analyticsId%22%3A%22%22%2C%22images%22%3A%7B%22deviceSizes%22%3A%5B640%2C750%2C828%2C1080%2C1200%2C1920%2C2048%2C3840%5D%2C%22imageSizes%22%3A%5B16%2C32%2C48%2C64%2C96%2C128%2C256%2C384%5D%2C%22path%22%3A%22%2F_next%2Fimage%22%2C%22loader%22%3A%22default%22%2C%22loaderFile%22%3A%22%22%2C%22domains%22%3A%5B%5D%2C%22disableStaticImages%22%3Afalse%2C%22minimumCacheTTL%22%3A60%2C%22formats%22%3A%5B%22image%2Fwebp%22%5D%2C%22dangerouslyAllowSVG%22%3Afalse%2C%22contentSecurityPolicy%22%3A%22script-src%20'none'%3B%20frame-src%20'none'%3B%20sandbox%3B%22%2C%22contentDispositionType%22%3A%22inline%22%2C%22remotePatterns%22%3A%5B%5D%2C%22unoptimized%22%3Afalse%7D%2C%22devIndicators%22%3A%7B%22buildActivity%22%3Atrue%2C%22buildActivityPosition%22%3A%22bottom-right%22%7D%2C%22onDemandEntries%22%3A%7B%22maxInactiveAge%22%3A15000%2C%22pagesBufferLength%22%3A2%7D%2C%22amp%22%3A%7B%22canonicalBase%22%3A%22%22%7D%2C%22basePath%22%3A%22%22%2C%22sassOptions%22%3A%7B%7D%2C%22trailingSlash%22%3Afalse%2C%22i18n%22%3Anull%2C%22productionBrowserSourceMaps%22%3Afalse%2C%22optimizeFonts%22%3Atrue%2C%22excludeDefaultMomentLocales%22%3Atrue%2C%22serverRuntimeConfig%22%3A%7B%7D%2C%22publicRuntimeConfig%22%3A%7B%7D%2C%22reactStrictMode%22%3Atrue%2C%22httpAgentOptions%22%3A%7B%22keepAlive%22%3Atrue%7D%2C%22outputFileTracing%22%3Atrue%2C%22staticPageGenerationTimeout%22%3A60%2C%22swcMinify%22%3Atrue%2C%22experimental%22%3A%7B%22clientRouterFilter%22%3Afalse%2C%22clientRouterFilterRedirects%22%3Afalse%2C%22fetchCacheKeyPrefix%22%3A%22%22%2C%22middlewarePrefetch%22%3A%22flexible%22%2C%22optimisticClientCache%22%3Atrue%2C%22runtime%22%3A%22edge%22%2C%22manualClientBasePath%22%3Afalse%2C%22legacyBrowsers%22%3Afalse%2C%22newNextLinkBehavior%22%3Atrue%2C%22cpus%22%3A3%2C%22sharedPool%22%3Atrue%2C%22isrFlushToDisk%22%3Atrue%2C%22workerThreads%22%3Afalse%2C%22pageEnv%22%3Afalse%2C%22optimizeCss%22%3Afalse%2C%22nextScriptWorkers%22%3Afalse%2C%22scrollRestoration%22%3Afalse%2C%22externalDir%22%3Afalse%2C%22disableOptimizedLoading%22%3Afalse%2C%22gzipSize%22%3Atrue%2C%22swcFileReading%22%3Atrue%2C%22craCompat%22%3Afalse%2C%22esmExternals%22%3Atrue%2C%22appDir%22%3Afalse%2C%22isrMemoryCacheSize%22%3A52428800%2C%22fullySpecified%22%3Afalse%2C%22outputFileTracingRoot%22%3A%22%2Fopt%2Fbuildhome%2Frepo%22%2C%22swcTraceProfiling%22%3Afalse%2C%22forceSwcTransforms%22%3Afalse%2C%22largePageDataBytes%22%3A128000%2C%22enableUndici%22%3Afalse%2C%22adjustFontFallbacks%22%3Afalse%2C%22adjustFontFallbacksWithSizeAdjust%22%3Afalse%2C%22typedRoutes%22%3Afalse%2C%22instrumentationHook%22%3Afalse%7D%2C%22configFile%22%3A%22%2Fopt%2Fbuildhome%2Frepo%2Fnext.config.js%22%2C%22configFileName%22%3A%22next.config.js%22%7D&pagesType=pages&appDirLoader=&sriEnabled=false&incrementalCacheHandlerPath=!
2023-04-10T21:36:01.987223Z ▲
2023-04-10T21:36:01.987336Z ▲ ./node_modules/readable-stream/readable.js:10:0
2023-04-10T21:36:01.987444Z ▲ Module not found: Can't resolve 'stream'
2023-04-10T21:36:01.987563Z ▲
2023-04-10T21:36:01.987674Z ▲ https://nextjs.org/docs/messages/module-not-found
2023-04-10T21:36:01.98778Z ▲
2023-04-10T21:36:01.987909Z ▲ Import trace for requested module:
2023-04-10T21:36:01.988029Z ▲ ./node_modules/html-tokenize/index.js
2023-04-10T21:36:01.988136Z ▲ ./node_modules/@emotion/server/create-instance/dist/emotion-server-create-instance.browser.esm.js
2023-04-10T21:36:01.988242Z ▲ ./pages/_document.tsx
2023-04-10T21:36:01.988372Z ▲ ./node_modules/next/dist/build/webpack/loaders/next-edge-ssr-loader/index.js?absolute500Path=&absoluteAppPath=private-next-pages%2F_app.tsx&absoluteDocumentPath=private-next-pages%2F_document.tsx&absoluteErrorPath=next%2Fdist%2Fpages%2F_error&absolutePagePath=private-next-pages%2Findex.tsx&buildId=pACNkUCpKtwjMkmYi7v1Z&dev=false&isServerComponent=false&page=%2F&stringifiedConfig=%7B%22env%22%3A%7B%22REQUIRE_USER_API_KEYS%22%3Atrue%7D%2C%22eslint%22%3A%7B%22ignoreDuringBuilds%22%3Afalse%7D%2C%22typescript%22%3A%7B%22ignoreBuildErrors%22%3Afalse%2C%22tsconfigPath%22%3A%22tsconfig.json%22%7D%2C%22distDir%22%3A%22.next%22%2C%22cleanDistDir%22%3Atrue%2C%22assetPrefix%22%3A%22%22%2C%22configOrigin%22%3A%22next.config.js%22%2C%22useFileSystemPublicRoutes%22%3Atrue%2C%22generateEtags%22%3Atrue%2C%22pageExtensions%22%3A%5B%22tsx%22%2C%22ts%22%2C%22jsx%22%2C%22js%22%5D%2C%22poweredByHeader%22%3Atrue%2C%22compress%22%3Atrue%2C%22analyticsId%22%3A%22%22%2C%22images%22%3A%7B%22deviceSizes%22%3A%5B640%2C750%2C828%2C1080%2C1200%2C1920%2C2048%2C3840%5D%2C%22imageSizes%22%3A%5B16%2C32%2C48%2C64%2C96%2C128%2C256%2C384%5D%2C%22path%22%3A%22%2F_next%2Fimage%22%2C%22loader%22%3A%22default%22%2C%22loaderFile%22%3A%22%22%2C%22domains%22%3A%5B%5D%2C%22disableStaticImages%22%3Afalse%2C%22minimumCacheTTL%22%3A60%2C%22formats%22%3A%5B%22image%2Fwebp%22%5D%2C%22dangerouslyAllowSVG%22%3Afalse%2C%22contentSecurityPolicy%22%3A%22script-src%20'none'%3B%20frame-src%20'none'%3B%20sandbox%3B%22%2C%22contentDispositionType%22%3A%22inline%22%2C%22remotePatterns%22%3A%5B%5D%2C%22unoptimized%22%3Afalse%7D%2C%22devIndicators%22%3A%7B%22buildActivity%22%3Atrue%2C%22buildActivityPosition%22%3A%22bottom-right%22%7D%2C%22onDemandEntries%22%3A%7B%22maxInactiveAge%22%3A15000%2C%22pagesBufferLength%22%3A2%7D%2C%22amp%22%3A%7B%22canonicalBase%22%3A%22%22%7D%2C%22basePath%22%3A%22%22%2C%22sassOptions%22%3A%7B%7D%2C%22trailingSlash%22%3Afalse%2C%22i18n%22%3Anull%2C%22productionBrowserSourceMaps%22%3Afalse%2C%22optimizeFonts%22%3Atrue%2C%22excludeDefaultMomentLocales%22%3Atrue%2C%22serverRuntimeConfig%22%3A%7B%7D%2C%22publicRuntimeConfig%22%3A%7B%7D%2C%22reactStrictMode%22%3Atrue%2C%22httpAgentOptions%22%3A%7B%22keepAlive%22%3Atrue%7D%2C%22outputFileTracing%22%3Atrue%2C%22staticPageGenerationTimeout%22%3A60%2C%22swcMinify%22%3Atrue%2C%22experimental%22%3A%7B%22clientRouterFilter%22%3Afalse%2C%22clientRouterFilterRedirects%22%3Afalse%2C%22fetchCacheKeyPrefix%22%3A%22%22%2C%22middlewarePrefetch%22%3A%22flexible%22%2C%22optimisticClientCache%22%3Atrue%2C%22runtime%22%3A%22edge%22%2C%22manualClientBasePath%22%3Afalse%2C%22legacyBrowsers%22%3Afalse%2C%22newNextLinkBehavior%22%3Atrue%2C%22cpus%22%3A3%2C%22sharedPool%22%3Atrue%2C%22isrFlushToDisk%22%3Atrue%2C%22workerThreads%22%3Afalse%2C%22pageEnv%22%3Afalse%2C%22optimizeCss%22%3Afalse%2C%22nextScriptWorkers%22%3Afalse%2C%22scrollRestoration%22%3Afalse%2C%22externalDir%22%3Afalse%2C%22disableOptimizedLoading%22%3Afalse%2C%22gzipSize%22%3Atrue%2C%22swcFileReading%22%3Atrue%2C%22craCompat%22%3Afalse%2C%22esmExternals%22%3Atrue%2C%22appDir%22%3Afalse%2C%22isrMemoryCacheSize%22%3A52428800%2C%22fullySpecified%22%3Afalse%2C%22outputFileTracingRoot%22%3A%22%2Fopt%2Fbuildhome%2Frepo%22%2C%22swcTraceProfiling%22%3Afalse%2C%22forceSwcTransforms%22%3Afalse%2C%22largePageDataBytes%22%3A128000%2C%22enableUndici%22%3Afalse%2C%22adjustFontFallbacks%22%3Afalse%2C%22adjustFontFallbacksWithSizeAdjust%22%3Afalse%2C%22typedRoutes%22%3Afalse%2C%22instrumentationHook%22%3Afalse%7D%2C%22configFile%22%3A%22%2Fopt%2Fbuildhome%2Frepo%2Fnext.config.js%22%2C%22configFileName%22%3A%22next.config.js%22%7D&pagesType=pages&appDirLoader=&sriEnabled=false&incrementalCacheHandlerPath=!
2023-04-10T21:36:01.988523Z ▲
2023-04-10T21:36:01.98866Z ▲
2023-04-10T21:36:01.988779Z ▲ > webpack config.resolve.alias was incorrectly overridden. https://nextjs.org/docs/messages/invalid-resolve-alias
2023-04-10T21:36:02.044658Z ▲ Error: Command "npm run build" exited with 1
2023-04-10T21:36:02.183977Z /opt/buildhome/.npm/_npx/39e2fd552b408994/node_modules/@cloudflare/next-on-pages/dist/index.js:12981
2023-04-10T21:36:02.184456Z cliError(err.message);
2023-04-10T21:36:02.1847Z ^
2023-04-10T21:36:02.184881Z
2023-04-10T21:36:02.185049Z TypeError: Cannot read properties of undefined (reading 'message')
2023-04-10T21:36:02.185215Z at buildApplication (/opt/buildhome/.npm/_npx/39e2fd552b408994/node_modules/@cloudflare/next-on-pages/dist/index.js:12981:20)
2023-04-10T21:36:02.185392Z at async /opt/buildhome/.npm/_npx/39e2fd552b408994/node_modules/@cloudflare/next-on-pages/dist/index.js:13085:7
2023-04-10T21:36:02.185615Z
2023-04-10T21:36:02.185802Z Node.js v17.9.1
2023-04-10T21:36:02.22652Z Failed: build command exited with code: 1
2023-04-10T21:36:03.423288Z Failed: error occurred while running build command
Hi @centminmod 🙂
as you mentioned in order to run on Cloudflare Pages you need to specify the edge runtime, but it is advised to do so per route instead of setting it in the next.config.js file.
So instead of your change I added the config to the publish api route and that seems to fix the issue and the app builds successfully.
I've opened this PR: nextjs-chatgpt-app#74 , please have a look and let me know if that works for you as well
@dario-piotrowicz thanks that worked perfectly on my forked repo and now builds again! ❤️
@centminmod awesome! I'm glad we solved it 😄
Closing the issue since I believe it's all good now, if you still have some issues please let me know 🙂
Hey, I encountered the same issue. I tried to add
export const config = {
runtime: 'edge',
};
in the files it asked to. also added it in the next.config.js
(this was not recommended but still a try)
const nextConfig = {
// configs
experimental: {
runtime: 'edge',
},
}
But still i got this same error. I thought its cached and that's why its not changing ? (just a thought) so i added a new file called teapot. its the same.
Repo: https://github.com/Rahuletto/CodeBoard I know I'm the one messing up. But would love to know what
I looked at your pr https://github.com/enricoros/nextjs-chatgpt-app/pull/74 and implemented the same. Still the same.
Cli version
@cloudflare/next-on-pages CLI v.0.7.0
Next.js related information
No response
Vercel version
Vercel CLI 28.18.4
Description
Hi I am new to nextjs and Cloudflare Pages usage and my first experience was building nextjs-chatgpt-app at https://github.com/enricoros/nextjs-chatgpt-app but last few builds haven't been successful and not sure if the issue is on either side? I also logged the error at https://github.com/enricoros/nextjs-chatgpt-app/issues/72
the latest build log
Reproduction
The Github repo built against was https://github.com/centminmod/nextjs-chatgpt-app.
The basics of Cloudflare Pages steps for building the app that worked previously was as follows:
For setting up your nextjs app on Cloudflare Pages you can follow Cloudflare developer docs at https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/ and https://developers.cloudflare.com/pages/platform/build-configuration/
The only difference is I took these steps below:
Create a project
button >Connect To Git
and give Cloudflare Pages either All Github account Repo access or selected Repo access. I use selected Repo access and select the forked repo from step 1Begin Setup
button to setup build and deployments. On this page you set youProject name
,Production branch
i.e. main and your Build settings where you select fromFramework preset
dropdown menuNext.js
. Leave the preset filled Build command and Build output directory as preset defaults. You'd want to setEnvironmental variables
(advanced) on this page to configure some variables as follows:*.YOURPROJECT.pages.dev
domain see https://developers.cloudflare.com/pages/platform/known-issues/#enabling-access-on-your-pagesdev-domain and enable Web AnalyticsAdditional Information
No response
Would you like to help?