Open
Description
Describe the Bug
Project structure: monorepo with [email protected]
I created a dedicated internal package to communicate with the CMS called @test/api. I want to use it in my internal monorepo app called @test/app. After I import import { fetchStuff } from @test/api
in my Next.js app, there is an error as shown below.
Everything works if I connect to Payload directly inside my app.
Module not found: Can't resolve 'child_process'
4 | 'use strict';
5 |
> 6 | const childProcess = require('child_process');
| ^
7 | const { isLinux, getReport } = require('./process');
8 | const { LDD_PATH, readFile, readFileSync } = require('./filesystem');
9 |
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
../../node_modules/sharp/lib/utility.js
../../node_modules/sharp/lib/index.js
../cms/src/payload.config.ts
../api/src/index.ts
./pages/index.js
⨯ ../../node_modules/detect-libc/lib/detect-libc.js:6:1
In the Next.js error dialog, you will probably see a different error like
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type; currently, no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
But my actual application shows the same error.
Link to the code that reproduces this issue
https://github.com/RafalFilipek/payload-monorepo-detect-libc-bug
Reproduction Steps
- Download repo
- Install dependencies with
[email protected]
- Run application located in
packages/app
(yarn dev
) - Open
http://localhost:3000
Which area(s) are affected? (Select all that apply)
Not sure
Environment Info
Payload: latest
NodeJS: 20.11.0 / 22.x
NextJS: 15.2.3
macOS: 15.3