Next.js Discord

Discord Forum

Webpack Build Error: Missing VAR_ORIGINAL_PATHNAME in Next.js Project

Unanswered
Mike (grind edition 💪) posted this in #help-forum
Open in Discord
Avatar
Description:
I’m trying to build a Next.js project but keep encountering a Webpack error related to missing template variables. My goal is to successfully compile the project without any build errors.

Code:
I'm including the relevant code for each of the pages mentioned in the error below:

- src/app/(auth)/signin/page.tsx
- src/app/(auth)/signup/page.tsx
- src/app/(dashboard)/dashboard/page.tsx
- src/app/(legal)/copyright/page.tsx
- src/app/(legal)/privacy/page.tsx

Error Logs:
Failed to compile.

src\app\(auth)\signin\page.tsx
Invariant: Expected to replace all template variables, missing VAR_ORIGINAL_PATHNAME in template

src\app\(auth)\signup\page.tsx
Invariant: Expected to replace all template variables, missing VAR_ORIGINAL_PATHNAME in template

src\app\(dashboard)\dashboard\page.tsx
Invariant: Expected to replace all template variables, missing VAR_ORIGINAL_PATHNAME in template

src\app\(legal)\copyright\page.tsx
Invariant: Expected to replace all template variables, missing VAR_ORIGINAL_PATHNAME in template

src\app\(legal)\privacy\page.tsx
Invariant: Expected to replace all template variables, missing VAR_ORIGINAL_PATHNAME in template

> Build failed because of webpack errors
error: script "build" exited with code 1


What I’ve Tried:
- Checked if the VAR_ORIGINAL_PATHNAME variable is defined in each of the files listed, but I couldn’t find any documentation on it.
- Searched for similar issues in the Next.js and Webpack documentation without success.
- Tried adding placeholders for VAR_ORIGINAL_PATHNAME but still encountered the same error.

Any insights or suggestions on resolving this issue would be greatly appreciated!
Image

0 Replies