next-runtime
next-runtime copied to clipboard
[Bug]: Cannot read properties of undefined (reading 'replace')
Summary
Got issue when deploying nextjs app using netlify
here is the full log from netlify
1:11:29 AM: Build ready to start
1:11:30 AM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
1:11:30 AM: build-image tag: v4.10.1
1:11:30 AM: buildbot version: 37262c48b1f3cfa88c6caed707d29b19aef6a5a7
1:11:30 AM: Fetching cached dependencies
1:11:30 AM: Failed to fetch cache, continuing with build
1:11:30 AM: Starting to prepare the repo for build
1:11:31 AM: No cached dependencies found. Cloning fresh repo
1:11:31 AM: git clone https://github.com/mlazuardy/hangry-customer-next
1:11:31 AM: Preparing Git Reference refs/heads/develop
1:11:32 AM: Parsing package.json dependencies
1:11:32 AM: Different build dir detected, going to use the one specified in the Netlify configuration file: '' versus '/' in the Netlify UI
1:11:33 AM: Starting build script
1:11:33 AM: Installing dependencies
1:11:33 AM: Python version set to 2.7
1:11:33 AM: Downloading and installing node v16.17.0...
1:11:33 AM: Downloading https://nodejs.org/dist/v16.17.0/node-v16.17.0-linux-x64.tar.xz...
1:11:33 AM: Computing checksum with sha256sum
1:11:34 AM: Checksums matched!
1:11:35 AM: Now using node v16.17.0 (npm v8.15.0)
1:11:35 AM: Started restoring cached build plugins
1:11:35 AM: Finished restoring cached build plugins
1:11:36 AM: Attempting ruby version 2.7.2, read from environment
1:11:36 AM: Using ruby version 2.7.2
1:11:36 AM: Using PHP version 8.0
1:11:36 AM: Started restoring cached yarn cache
1:11:36 AM: Finished restoring cached yarn cache
1:11:37 AM: No yarn workspaces detected
1:11:37 AM: Started restoring cached node modules
1:11:37 AM: Finished restoring cached node modules
1:11:37 AM: Installing NPM modules using Yarn version 1.22.10
1:11:37 AM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
1:11:37 AM: npm WARN config location in the cache, and they are managed by
1:11:37 AM: npm WARN config [`cacache`](http://npm.im/cacache).
1:11:37 AM: yarn install v1.22.10
1:11:37 AM: [1/4] Resolving packages...
1:11:37 AM: [2/4] Fetching packages...
1:11:54 AM: info [email protected]: The platform "linux" is incompatible with this module.
1:11:54 AM: info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
1:11:54 AM: info @next/[email protected]: The platform "linux" is incompatible with this module.
1:11:54 AM: info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
1:11:54 AM: info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
1:11:54 AM: info @next/[email protected]: The platform "linux" is incompatible with this module.
1:11:54 AM: info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
1:11:54 AM: info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
1:11:54 AM: info @next/[email protected]: The platform "linux" is incompatible with this module.
1:11:54 AM: info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
1:11:54 AM: info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
1:11:54 AM: info @next/[email protected]: The platform "linux" is incompatible with this module.
1:11:54 AM: info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
1:11:54 AM: info @next/[email protected]: The platform "linux" is incompatible with this module.
1:11:54 AM: info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
1:11:54 AM: info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
1:11:54 AM: info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
1:11:54 AM: info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
1:11:54 AM: info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
1:11:54 AM: info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
1:11:54 AM: info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
1:11:54 AM: info @next/[email protected]: The platform "linux" is incompatible with this module.
1:11:54 AM: info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
1:11:54 AM: info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
1:11:54 AM: info @next/[email protected]: The platform "linux" is incompatible with this module.
1:11:54 AM: info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
1:11:54 AM: info @next/[email protected]: The CPU architecture "x64" is incompatible with this module.
1:11:54 AM: info @next/[email protected]: The platform "linux" is incompatible with this module.
1:11:54 AM: info "@next/[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
1:11:54 AM: [3/4] Linking dependencies...
1:11:54 AM: warning "@sentry/nextjs > [email protected]" has unmet peer dependency "@babel/preset-env@^7.1.6".
1:11:54 AM: warning "next-pwa > [email protected]" has unmet peer dependency "@babel/core@^7.0.0".
1:12:01 AM: [4/4] Building fresh packages...
1:12:03 AM: Done in 26.23s.
1:12:03 AM: NPM modules installed using Yarn
1:12:04 AM: Started restoring cached go cache
1:12:04 AM: Finished restoring cached go cache
1:12:04 AM: Installing Go version 1.17 (requested 1.17)
1:12:08 AM: unset GOOS;
1:12:08 AM: unset GOARCH;
1:12:08 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
1:12:08 AM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
1:12:08 AM: go version >&2;
1:12:08 AM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
1:12:08 AM: go version go1.17 linux/amd64
1:12:08 AM: Installing missing commands
1:12:08 AM: Verify run directory
1:12:09 AM:
1:12:09 AM: ────────────────────────────────────────────────────────────────
1:12:09 AM: Netlify Build
1:12:09 AM: ────────────────────────────────────────────────────────────────
1:12:09 AM:
1:12:09 AM: ❯ Version
1:12:09 AM: @netlify/build 27.17.1
1:12:09 AM:
1:12:09 AM: ❯ Flags
1:12:09 AM: baseRelDir: true
1:12:09 AM: buildId: 6320c7d0a865660dcf070d29
1:12:09 AM: deployId: 6320c7d0a865660dcf070d2b
1:12:09 AM:
1:12:09 AM: ❯ Current directory
1:12:09 AM: /opt/build/repo
1:12:09 AM:
1:12:09 AM: ❯ Config file
1:12:09 AM: No config file was defined: using default values.
1:12:09 AM:
1:12:09 AM: ❯ Context
1:12:09 AM: production
1:12:10 AM:
1:12:10 AM: ❯ Installing plugins
1:12:10 AM: - @netlify/[email protected]
1:12:17 AM:
1:12:17 AM: ❯ Loading plugins
1:12:17 AM: - @netlify/[email protected] from Netlify app
1:12:17 AM:
1:12:17 AM: ────────────────────────────────────────────────────────────────
1:12:17 AM: 1. @netlify/plugin-nextjs (onPreBuild event)
1:12:17 AM: ────────────────────────────────────────────────────────────────
1:12:17 AM:
1:12:17 AM: No Next.js cache to restore.
1:12:17 AM: Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed.
1:12:18 AM:
1:12:18 AM: (@netlify/plugin-nextjs onPreBuild completed in 20ms)
1:12:18 AM:
1:12:18 AM: ────────────────────────────────────────────────────────────────
1:12:18 AM: 2. Build command from Netlify app
1:12:18 AM: ────────────────────────────────────────────────────────────────
1:12:18 AM:
1:12:18 AM: $ yarn build
1:12:18 AM: yarn run v1.22.10
1:12:18 AM: $ node scripts/pre-build.script.js && next build
1:12:18 AM: JSON file has been saved.
1:12:19 AM: warn - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
1:12:19 AM: info - Linting and checking validity of types...
1:12:27 AM: info - Creating an optimized production build...
1:12:28 AM: > [PWA] Compile client (static)
1:12:28 AM: > [PWA] Auto register service worker with: /opt/build/repo/node_modules/next-pwa/register.js
1:12:28 AM: > [PWA] Service worker: /opt/build/repo/public/sw.js
1:12:28 AM: > [PWA] url: /sw.js
1:12:28 AM: > [PWA] scope: /
1:12:28 AM: > [PWA] Compile server
1:12:28 AM: > [PWA] Compile server
1:12:52 AM: warn - Compiled with warnings
1:12:52 AM: /_next/static/chunks/pages/_app-969f5100810ad7a5.js.map is 3.94 MB, and won't be precached. Configure maximumFileSizeToCacheInBytes to change this limit.
1:12:52 AM: info - Collecting page data...
1:12:59 AM: info - Generating static pages (0/13)
1:13:01 AM: info - Generating static pages (3/13)
1:13:01 AM: info - Generating static pages (6/13)
1:13:01 AM: info - Generating static pages (9/13)
1:13:02 AM: info - Generating static pages (13/13)
1:13:02 AM: info - Finalizing page optimization...
1:13:02 AM: Route (pages) Size First Load JS
1:13:02 AM: ┌ ○ / (1922 ms) 8.11 kB 267 kB
1:13:02 AM: ├ /_app 0 B 226 kB
1:13:02 AM: ├ λ /[restaurant] 2.21 kB 290 kB
1:13:02 AM: ├ λ /[restaurant]/table-orders/[table] 6.9 kB 313 kB
1:13:02 AM: ├ ○ /@ (1923 ms) 1.72 kB 261 kB
1:13:02 AM: ├ ○ /@/addresses (1898 ms) 1.81 kB 261 kB
1:13:02 AM: ├ ○ /@/messages (1964 ms) 6.26 kB 265 kB
1:13:02 AM: ├ ○ /@/orders (1905 ms) 6.85 kB 274 kB
1:13:02 AM: ├ ○ /@/orders/[id] (2010 ms) 15.4 kB 300 kB
1:13:02 AM: ├ ○ /@/rewards (1847 ms) 1.15 kB 260 kB
1:13:02 AM: ├ ○ /@/rewards/[id] 7.11 kB 266 kB
1:13:02 AM: ├ ○ /@/setting (1806 ms) 2.06 kB 272 kB
1:13:02 AM: ├ ○ /404 (1799 ms) 3.02 kB 256 kB
1:13:02 AM: ├ λ /api/setting 0 B 226 kB
1:13:02 AM: ├ ○ /auth/login (1978 ms) 5.98 kB 260 kB
1:13:02 AM: ├ ○ /cart (2001 ms) 3.14 kB 300 kB
1:13:02 AM: └ ○ /change-email (1802 ms) 1.92 kB 231 kB
1:13:02 AM: + First Load JS shared by all 235 kB
1:13:02 AM: ├ chunks/framework-fe99aa755573eedd.js 45.5 kB
1:13:02 AM: ├ chunks/main-309b892836205b4e.js 33.2 kB
1:13:02 AM: ├ chunks/pages/_app-969f5100810ad7a5.js 147 kB
1:13:02 AM: ├ chunks/webpack-c32e189195376b8d.js 1.15 kB
1:13:02 AM: └ css/7e8082508805c553.css 8.84 kB
1:13:02 AM: ƒ Middleware 19.9 kB
1:13:02 AM: λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
1:13:02 AM: ○ (Static) automatically rendered as static HTML (uses no initial props)
1:13:02 AM: Done in 44.52s.
1:13:02 AM:
1:13:02 AM: (build.command completed in 44.6s)
1:13:02 AM:
1:13:02 AM: ────────────────────────────────────────────────────────────────
1:13:02 AM: 3. @netlify/plugin-nextjs (onBuild event)
1:13:02 AM: ────────────────────────────────────────────────────────────────
1:13:02 AM:
1:13:02 AM: Patching /opt/build/repo/node_modules/next/dist/server/base-server.js
1:13:02 AM: Done
1:13:02 AM: Patching /opt/build/repo/node_modules/next/dist/server/next-server.js
1:13:02 AM: Done
1:13:02 AM: Moving static page files to serve from CDN...
1:13:02 AM: Moved 10 files
1:13:02 AM:
1:13:02 AM: ────────────────────────────────────────────────────────────────
1:13:02 AM: Plugin "@netlify/plugin-nextjs" internal error
1:13:02 AM: ────────────────────────────────────────────────────────────────
1:13:02 AM:
1:13:02 AM: Error message
1:13:02 AM: TypeError: Cannot read properties of undefined (reading 'replace')
1:13:02 AM:
1:13:02 AM: Plugin details
1:13:02 AM: Package: @netlify/plugin-nextjs
1:13:02 AM: Version: 4.22.0
1:13:02 AM: Repository: git+https://github.com/netlify/next-runtime.git
1:13:02 AM: npm link: https://www.npmjs.com/package/@netlify/plugin-nextjs
1:13:02 AM: Report issues: https://github.com/netlify/next-runtime/issues
1:13:02 AM:
1:13:02 AM: Error location
1:13:02 AM: In "onBuild" event in "@netlify/plugin-nextjs" from Netlify app
1:13:02 AM: at stripLookahead (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/lib/helpers/edge.js:49:41)
1:13:02 AM: at writeEdgeFunction (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/lib/helpers/edge.js:67:18)
1:13:02 AM: at async writeEdgeFunctions (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/lib/helpers/edge.js:122:40)
1:13:02 AM: at async onBuild (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/lib/index.js:110:13)
1:13:02 AM: at async Object.run (file:///opt/buildhome/node-deps/node_modules/@netlify/build/src/plugins/child/run.js:21:3)
1:13:02 AM: at async handleEvent (file:///opt/buildhome/node-deps/node_modules/@netlify/build/src/plugins/child/main.js:41:38)
1:13:02 AM: at async process.<anonymous> (file:///opt/buildhome/node-deps/node_modules/@netlify/build/src/plugins/ipc.js:112:16)
1:13:02 AM:
1:13:02 AM: Resolved config
1:13:02 AM: build:
1:13:02 AM: base: /opt/build/repo
1:13:02 AM: command: yarn build
1:13:02 AM: commandOrigin: ui
1:13:02 AM: environment:
1:13:02 AM: - NETLIFY_GRAPH_TOKEN
1:13:02 AM: - NEXT_DISABLE_EDGE_IMAGES
1:13:02 AM: - NEXT_PUBLIC_API_URL
1:13:02 AM: - NEXT_PUBLIC_APP_BUILD
1:13:02 AM: - NEXT_PUBLIC_APP_ENV
1:13:02 AM: - NEXT_PUBLIC_APP_VERSION
1:13:02 AM: - NEXT_PUBLIC_FCM_API_KEY
1:13:02 AM: - NEXT_PUBLIC_FCM_APP_ID
1:13:02 AM: - NEXT_PUBLIC_FCM_MEASUREMENT_ID
1:13:02 AM: - NEXT_PUBLIC_FCM_PROJECT_ID
1:13:02 AM: - NEXT_PUBLIC_FCM_SENDER_ID
1:13:02 AM: - NEXT_PUBLIC_FCM_VAPID_KEY
1:13:02 AM: - NEXT_PUBLIC_GMAP_KEY
1:13:02 AM: - NEXT_PUBLIC_HANGRY_URL
1:13:02 AM: - NEXT_PUBLIC_PUSHER_CLUSTER
1:13:02 AM: - NEXT_PUBLIC_PUSHER_KEY
1:13:02 AM: - NEXT_PUBLIC_SENTRY_DSN
1:13:02 AM: - NEXT_PUBLIC_STRIPE_KEY
1:13:02 AM: - ONEGRAPH_AUTHLIFY_TOKEN
1:13:02 AM: - PWA_ENABLED
1:13:02 AM: - SENTRY_AUTH_TOKEN
1:13:02 AM: - NEXT_PRIVATE_TARGET
1:13:02 AM: publish: /opt/build/repo/.next
1:13:02 AM: publishOrigin: ui
1:13:02 AM: plugins:
1:13:02 AM: - inputs: {}
1:13:02 AM: origin: ui
1:13:02 AM: package: '@netlify/plugin-nextjs'
1:13:03 AM: Caching artifacts
1:13:03 AM: Started saving node modules
1:13:03 AM: Finished saving node modules
1:13:03 AM: Started saving build plugins
1:13:03 AM: Finished saving build plugins
1:13:03 AM: Started saving yarn cache
1:13:06 AM: Finished saving yarn cache
1:13:06 AM: Started saving pip cache
1:13:06 AM: Finished saving pip cache
1:13:06 AM: Started saving emacs cask dependencies
1:13:06 AM: Finished saving emacs cask dependencies
1:13:06 AM: Started saving maven dependencies
1:13:06 AM: Finished saving maven dependencies
1:13:06 AM: Started saving boot dependencies
1:13:07 AM: Creating deploy upload records
1:13:06 AM: Finished saving boot dependencies
1:13:06 AM: Started saving rust rustup cache
1:13:06 AM: Finished saving rust rustup cache
1:13:06 AM: Started saving go dependencies
1:13:08 AM: Failed during stage 'building site': Build script returned non-zero exit code: 3
1:13:06 AM: Finished saving go dependencies
1:13:07 AM: Build failed due to a plugin error: Build script returned non-zero exit code: 3
1:13:08 AM: Failing build: Failed to build site
1:13:08 AM: Finished processing build request in 1m37.508903837s
Steps to reproduce
- Deploy Site
A link to a reproduction repository
No response
Next Runtime version
4.22.0
More information about your build
- [ ] I am building using the CLI
- [ ] I am building using file-based configuration (
netlify.toml
)
What OS are you using?
No response
Your netlify.toml file
`netlify.toml`
# Paste content of your `netlify.toml` file here
Your public/_redirects file
`_redirects`
# Paste content of your `_redirects` file here
Your next.config.js
file
`next.config.js`
# Paste content of your `next.config.js` file here. Check there is no private info in there.
Builds logs (or link to your logs)
Build logs
# Paste logs here
Function logs
Function logs
# Paste logs here
.next JSON files
generated .next JSON files
# Paste file contents here. Please check there isn't any private info in them
# You can either build locally, or download the deploy from Netlify by clicking the arrow next to the deploy time.
I've also just found that I'm getting this issue if I add a "middleware.ts" file to in the root of the build.
I got this issue when upgrading to [email protected]
.
Downgrading back to [email protected]
allowed the plugin to complete building.
Thanks to @stwilz for the hint.
Thanks for reporting this! Just taking a peek at this.
Hi @ShuPink, is this still an issue for you? We've made a lot of changes since this issue was opened originally.
@nickytonline I'm actually still on [email protected]
😳 I'll try upgrading tomorrow and see if it builds
@nickytonline builds fine for me now on [email protected]
with the [email protected]
Thanks for following up 👍