Home
Support Forums

TypeError: isDynamicRoute is not a function

I am using next-on-netlify package version 2.9.0. its support isr in my nextjs project that is deployed in netlify.now building the site become an error like below throwing.

/opt/build/repo/node_modules/next-on-netlify/lib/steps/setupRedirects.js:41
10:03:22 AM:     ({ route }) => !isDynamicRoute(removeFileExtension(route))
10:03:22 AM:                     ^
10:03:22 AM: TypeError: isDynamicRoute is not a function
10:03:22 AM:     at /opt/build/repo/node_modules/next-on-netlify/lib/steps/setupRedirects.js:41:21
10:03:22 AM:     at Array.filter (<anonymous>)
10:03:22 AM:     at setupRedirects (/opt/build/repo/node_modules/next-on-netlify/lib/steps/setupRedirects.js:40:41)
10:03:22 AM:     at build (/opt/build/repo/node_modules/next-on-netlify/index.js:35:3)
10:03:22 AM:     at nextOnNetlify (/opt/build/repo/node_modules/next-on-netlify/index.js:80:7)
10:03:22 AM:     at Command.<anonymous> (/opt/build/repo/node_modules/next-on-netlify/next-on-netlify.js:23:5)
10:03:22 AM:     at Command.listener [as _actionHandler] (/opt/build/repo/node_modules/next-on-netlify/node_modules/commander/index.js:426:31)
10:03:22 AM:     at Command._parseCommand (/opt/build/repo/node_modules/next-on-netlify/node_modules/commander/index.js:1002:14)
10:03:22 AM:     at Command._dispatchSubcommand (/opt/build/repo/node_modules/next-on-netlify/node_modules/commander/index.js:953:18)
10:03:22 AM:     at Command._parseCommand (/opt/build/repo/node_modules/next-on-netlify/node_modules/commander/index.js:979:12)
10:03:22 AM: npm ERR! code ELIFECYCLE
10:03:22 AM: npm ERR! errno 1
10:03:22 AM: npm ERR! platformproperty@0.1.1 postbuild: `next-on-netlify`
10:03:22 AM: npm ERR! Exit status 1
10:03:22 AM: npm ERR!
10:03:22 AM: npm ERR! Failed at the platformproperty@0.1.1 postbuild script.
10:03:22 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:03:22 AM: npm ERR! A complete log of this run can be found in:
10:03:22 AM: npm ERR!     /opt/buildhome/.npm/_logs/2021-10-27T04_33_22_456Z-debug.log
10:03:22 AM: ​
10:03:22 AM: ────────────────────────────────────────────────────────────────
10:03:22 AM:   "build.command" failed                                        
10:03:22 AM: ────────────────────────────────────────────────────────────────
10:03:22 AM: ​
10:03:22 AM:   Error message
10:03:22 AM:   Command failed with exit code 1: npm run build
10:03:22 AM: ​
10:03:22 AM:   Error location
10:03:22 AM:   In build.command from netlify.toml:
10:03:22 AM:   npm run build
10:03:22 AM: ​
10:03:22 AM:   Resolved config
10:03:22 AM:   build:
10:03:22 AM:     command: npm run build
10:03:22 AM:     commandOrigin: config
10:03:22 AM:     environment:
10:03:22 AM:       - REVIEW_ID
10:03:22 AM:     publish: /opt/build/repo/out_publish
10:03:22 AM:     publishOrigin: config
10:03:22 AM:   functionsDirectory: /opt/build/repo/out_functions
10:03:22 AM:   plugins:
10:03:22 AM:     - inputs: {}
10:03:22 AM:       origin: ui
10:03:22 AM:       package: netlify-plugin-cache-nextjs
10:03:22 AM: Caching artifacts
10:03:22 AM: Started saving node modules
10:03:22 AM: Finished saving node modules
10:03:22 AM: Started saving build plugins
10:03:22 AM: Finished saving build plugins
10:03:22 AM: Started saving yarn cache
10:03:26 AM: Finished saving yarn cache
10:03:26 AM: Started saving pip cache
10:03:26 AM: Finished saving pip cache
10:03:26 AM: Started saving emacs cask dependencies
10:03:26 AM: Finished saving emacs cask dependencies
10:03:26 AM: Started saving maven dependencies
10:03:26 AM: Finished saving maven dependencies
10:03:26 AM: Started saving boot dependencies
10:03:26 AM: Finished saving boot dependencies
10:03:26 AM: Started saving rust rustup cache
10:03:26 AM: Finished saving rust rustup cache
10:03:26 AM: Started saving go dependencies
10:03:26 AM: Finished saving go dependencies
10:03:29 AM: Cached ruby version 2.7.1
10:03:29 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:03:29 AM: Creating deploy upload records
10:03:29 AM: Failing build: Failed to build site
10:03:29 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
10:03:29 AM: Finished processing build request in 3m17.076953s`Preformatted text`

Hey there,

Thanks for reaching out. Can you try using the beta version of our latest plugin to see if that helps here? You can see more information here.

If that doesn’t work, we will need a bit more information in order to debug this further. Can you please share your site name and your repo with us?

Thanks so much!

The issue is fixed when changing the version of next-on-netlify package from 2.9.0 to 3.0.1.

1 Like

Thanks so much for coming back and letting us know! Glad everything is working for you now.