Next.js Build is failing for the npm run build in the /frontend folder

Hey All, I am struggling with the build failure for the frontend project which is under mono project. My code has /frontend and /backend. I have configured the build path as /frontend, but it is failing to find the @lib path.
13:17:24.975 ./app/admin/account/call-logs/page.tsx
13:17:24.975 Module not found: Can't resolve '@/lib/api-utils'
13:17:24.975 ./app/admin/account/call-logs/page.tsx
13:17:24.975 Module not found: Can't resolve '@/lib/api-utils'
I have lib folder under /frontend, but it is still failing. The same is working in my local.
4 Replies
kapser
kapserOP4mo ago
build no: 5b58bb00-c32b-4879-8a87-b57a4274bc70 (if this helps to check what is happening)
gabriel
gabriel4mo ago
Can you please share your repo if possible? It seems like config issue like tsconfig or nextjs config
kapser
kapserOP4mo ago
It is a private repo. I can share the tsconfig and nextjs config tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"],
"@/lib/*": ["./src/lib/*"],
"@/components/*": ["./src/components/*"],
"@/hooks/*": ["./src/hooks/*"],
"@/types/*": ["./src/types/*"],
"@/services/*": ["./src/services/*"],
"@/app/*": ["./app/*"]
},
"jsxImportSource": "react"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules", "landing"]
}
{
"compilerOptions": {
"baseUrl": ".",
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"],
"@/lib/*": ["./src/lib/*"],
"@/components/*": ["./src/components/*"],
"@/hooks/*": ["./src/hooks/*"],
"@/types/*": ["./src/types/*"],
"@/services/*": ["./src/services/*"],
"@/app/*": ["./app/*"]
},
"jsxImportSource": "react"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules", "landing"]
}
and here is the next.config.js
/** @type {import('next').NextConfig} */
const path = require('path');

const nextConfig = {
output: 'standalone',
webpack: (config) => {
// Only add the essential @ alias
config.resolve.alias['@'] = path.resolve(__dirname);
return config;
},
async rewrites() {
return [
// Serve landing page assets
{
source: '/_landing/:path*',
destination: '/landing/:path*',
},
]
},
}

module.exports = nextConfig;
/** @type {import('next').NextConfig} */
const path = require('path');

const nextConfig = {
output: 'standalone',
webpack: (config) => {
// Only add the essential @ alias
config.resolve.alias['@'] = path.resolve(__dirname);
return config;
},
async rewrites() {
return [
// Serve landing page assets
{
source: '/_landing/:path*',
destination: '/landing/:path*',
},
]
},
}

module.exports = nextConfig;
gabriel
gabriel4mo ago
Please check case sensitivity of your directory names and clear cache using rm -rf .next node_modules, and try again npm i and npm run build

Did you find this page helpful?