Next.js: Build error: TypeError: Cannot read property 'replace' of undefined

Created on 21 Oct 2019  路  2Comments  路  Source: vercel/next.js

Getting this error while build ->

> Build error occurred
TypeError: Cannot read property 'replace' of undefined
    at Module.1TCz (/Users/Documents/SHIFT/create/eco-ui-ssr/src/.next/server/static/azPtrXenFyoDdfct9cPkm/pages/_app.js:408:23)
    at __webpack_require__ (/Users/Documents/SHIFT/create/eco-ui-ssr/src/.next/server/static/azPtrXenFyoDdfct9cPkm/pages/_app.js:23:31)
    at Object.0 (/Users/Documents/SHIFT/create/eco-ui-ssr/src/.next/server/static/azPtrXenFyoDdfct9cPkm/pages/_app.js:147:18)
    at __webpack_require__ (/Users/Documents/SHIFT/create/eco-ui-ssr/src/.next/server/static/azPtrXenFyoDdfct9cPkm/pages/_app.js:23:31)
    at /Users/Documents/SHIFT/create/eco-ui-ssr/src/.next/server/static/azPtrXenFyoDdfct9cPkm/pages/_app.js:91:18
    at Object.<anonymous> (/Users/Documents/SHIFT/create/eco-ui-ssr/src/.next/server/static/azPtrXenFyoDdfct9cPkm/pages/_app.js:94:10)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
  • Version of Next.js: 9.1.1

"dependencies": { "@apollo/react-hooks": "^3.1.1", "@apollo/react-ssr": "^3.1.1", "@material-ui/core": "^4.4.3", "@material-ui/icons": "^4.4.3", "@material-ui/styles": "^4.4.3", "apollo-cache-inmemory": "^1.6.3", "apollo-client": "^2.6.4", "apollo-link": "^1.2.13", "apollo-link-context": "^1.0.19", "apollo-link-error": "^1.1.12", "apollo-link-http": "^1.5.16", "apollo-link-ws": "^1.0.19", "apollo-utilities": "^1.3.2", "body-parser": "^1.19.0", "classnames": "^2.2.6", "compression": "^1.7.4", "cookie-parser": "^1.4.4", "cookie-session": "^1.3.3", "cors": "^2.8.5", "dotenv": "^8.1.0", "express": "^4.17.1", "express-pino-logger": "^4.0.0", "graphql": "^14.5.7", "graphql-tag": "^2.10.1", "helmet": "^3.21.1", "isomorphic-unfetch": "^3.0.0", "next": "^9.1.1", "passport": "^0.4.0", "passport-azure-ad": "^4.1.0", "pino": "^5.13.3", "react": "^16.9.0", "react-dom": "^16.9.0", "simple-oauth2": "^2.4.0", "subscriptions-transport-ws": "^0.9.16", "tinycolor2": "^1.4.1" }, "devDependencies": { "nodemon": "^1.19.2" }

Any guidance here will be appreciated.

Most helpful comment

After some troubleshooting, it seems ti be related to 'next/config' not returning env variables in prod build but does it correctly in dev.

All 2 comments

After some troubleshooting, it seems ti be related to 'next/config' not returning env variables in prod build but does it correctly in dev.

Please provide a full reproduction following the issue template.


Please follow the issue template.

https://github.com/zeit/next.js/issues/new/choose

https://github.com/zeit/next.js/issues/new?template=8.Question_about_next.md

# Question about Next.js

GitHub Issues are reserved for Bug reports and Feature requests. The best place to get your question answered is to post it on https://spectrum.chat/next-js.
Was this page helpful?
0 / 5 - 0 ratings