node.jswebpacknext.jsnpm-workspaces

Build fail in NextJS monorepo — HookWebpackError: processor is not a function


When I try to build one of the NextJS apps in my monorepo, I get the error:

$ rm -r packages/library/node_modules/; rm -r packages/daily/node_modules/; rm -r node_modules/; rm -r packages/shared/node_modules; rm package-lock.json; sudo rm -r packages/daily/.next/; npm i; npm --prefix packages/daily/ run build

> next build

info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
info  - Checking validity of types  
info  - Creating an optimized production build  

Failed to compile.

HookWebpackError: processor is not a function

> Build error occurred
Error: > Build failed because of webpack errors
    at /home/ubuntu/cal-frontend/packages/daily/node_modules/next/dist/build/index.js:397:19
    at async Span.traceAsyncFn (/home/ubuntu/cal-frontend/packages/daily/node_modules/next/dist/telemetry/trace/trace.js:60:20)
    at async Object.build [as default] (/home/ubuntu/cal-frontend/packages/daily/node_modules/next/dist/build/index.js:77:25)

The strange thing is that the node/npm version and code are exactly the same as a few days ago when I last ran this command successfully. I have never had this error before. I even tried cloning to a brand new Linux EC2 instance to see if there was some cached file screwing it up but I got exact same error. I am still able to re-deploy the latest commit on Heroku from a few days ago.

The next dev command works fine still.

The issue started happening when I tried to create a new website under packages/ . But the error is persisting even after I reverted to a commit before I made that code.

The monorepo contains two websites that share a package of shared code inside the repo called shared. Here is the webpack next.config.js file for the package/daily app. Again, no code has changed since the error started.

const withFonts = require('next-fonts');
const withTM = require('next-transpile-modules')(['@my-repo-name/shared']);
require('dotenv').config({ path: '../../.env' });

module.exports = withTM(withFonts({
  eslint: {
    // Warning: This allows production builds to successfully complete even if
    // your project has ESLint errors.
    ignoreDuringBuilds: true,
  },
  webpack(config, options) {
    return config;
  },
}));

node version: v16.10.0 npm version: 7.24.0

(I also tried building using 16.14 and 8.3, and had the same error)

Also the root level package.json (with personal details redacted):

{
  "name": "my-repo-name",
  "version": "1.0.0",
  "workspaces": {
    "packages": [
      "packages/*"
    ]
  },
  "keywords": [],
  "author": "redacted-for-stack-overflow@stackoverflow.org",
  "license": "UNLICENSED",
  "description": "REDACTED FOR STACK OVERFLOW",
  "engines": {
    "node": "16.10.0"
  },
  "cacheDirectories": [
    "node_modules",
    "packages/library/.next/cache"
  ],
  "scripts": {
    "lint": "eslint . --ext js,jsx",
    "build": "npm run build --prefix packages/$APP_NAME"
  },
  "dependencies": {},
  "devDependencies": {
    "babel-eslint": "^10.1.0",
    "eslint": "^7.32.0",
    "eslint-config-next": "^11.1.2",
    "eslint-plugin-import": "^2.24.2",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-react": "^7.26.1",
    "eslint-plugin-react-hooks": "^4.2.0"
  }
}

Solution

  • There was an incident yesterday which was causing the issue at Vercel. It should be fixed now.