question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read properties of undefined (reading 'replace')

See original GitHub issue

Versions

  • next: 13.0.0
  • next-with-less: 2.0.5
  • less-loader: 11.1.0
  • less: 4.1.3
  • antd: 4.24.4

next.config.js

const withLess = require("next-with-less");
/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
  lessLoaderOptions: {}
}

module.exports = withLess(nextConfig)

Error Message

TypeError: Cannot read properties of undefined (reading 'replace')
    at addLessToRegExp (/project/sandbox/node_modules/next-with-less/dist/index.js:21:31)
    at addLessToRuleTest (/project/sandbox/node_modules/next-with-less/dist/index.js:77:18)
    at /project/sandbox/node_modules/next-with-less/dist/index.js:87:23
    at Array.forEach (<anonymous>)
    at Object.webpack (/project/sandbox/node_modules/next-with-less/dist/index.js:81:21)
    at Object.getBaseWebpackConfig [as default] (/project/sandbox/node_modules/next/dist/build/webpack-config.js:1413:32)
    at async Promise.all (index 0)
    at async Span.traceAsyncFn (/project/sandbox/node_modules/next/dist/trace/trace.js:79:20)
    at async Span.traceAsyncFn (/project/sandbox/node_modules/next/dist/trace/trace.js:79:20)
    at async HotReloader.start (/project/sandbox/node_modules/next/dist/server/dev/hot-reloader.js:332:30)

image

Examples

nextjs-demo

Issue Analytics

  • State:open
  • Created 10 months ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
chemicalkosekcommented, Dec 13, 2022

I chose Ant Design as my component library, which generally works and looks good with my application, but only supports Less

AntD since 5.0 doesn’t use less. You can use this guide to migrate: https://ant.design/docs/react/migration-v5

1reaction
Zeng95commented, Dec 1, 2022

The error message shows up after installing @next/font with Next.js 13

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: Cannot read properties of undefined ...
In your example Uncaught TypeError: Cannot read properties of undefined (reading 'replace' ) can occur only if your variables song and/or ...
Read more >
[SOLVED] Cannot Read Property 'replace' of Undefined in JS
To fix the “cannot read property 'replace' of undefined” error, perform an undefined check on the variable before calling the replace() method ......
Read more >
TypeError: Cannot read property 'replace' of Undefined in JS
The "Cannot read property 'replace' of undefined" error occurs when calling the replace() method on an undefined value. To solve the error, provide...
Read more >
Cannot read property 'replace' of Undefined in JS - Isotropic
This can be very useful but sometimes runtime errors may come up while using this method such as TypeError: Cannot read properties of...
Read more >
Error in render: "TypeError: Cannot read property 'replace' of ...
This is the error got: Error in render: "TypeError: Cannot read property 'replace' of undefined". Note: I'm using ElementUI for uploading the image....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found