Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

next build error occrred from performace-relayer

Tags:

next.js

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

like image 629
cometa Avatar asked Oct 14 '25 13:10

cometa


1 Answers

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
like image 108
Ismoil Shokirov Avatar answered Oct 17 '25 23:10

Ismoil Shokirov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!