next build occurred error by
ReferenceError: location is not defined
at Object.<anonymous> (/PATH/node_modules/next/dist/client/performance-relayer.js:1:135)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/PATH/node_modules/next/dist/client/index.js:1:1406)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) {
type: 'ReferenceError'
I don't have any idea..
plz help
Generally, it happens because of incorrect import of NextJS components such as Link, router
For instance:
import {router} from "next/client"; // will cause location not found error
will cause this type of error. The correct way is as follows:
import router from "next/router"; // correct way
Same is with "Link":
import Link from "next/link"; // correct way
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With