Next.js Discord

Discord Forum

Import trace for requested module

Answered
Ocicat posted this in #help-forum
Open in Discord
OcicatOP
Module not found: Can't resolve 'child_process'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/bullmq/dist/esm/classes/child-pool.js
./node_modules/bullmq/dist/esm/classes/index.js
./node_modules/bullmq/dist/esm/index.js
./src/lib/context.ts
./src/app/admin/lib/utils.ts
./src/app/admin/lessons/lib/actions.ts
./src/app/admin/lessons/[lessonId]/form.tsx

Constantly getting terminal warns like this one, but then suddenly on a page it breaks with a client exception in dev.
- The page code has nothing special to other code at least obvious that would trigger this error.
- In my understanding. this happens because some code which is supposed to run on the server leaks n the client, but the client components are correctly marked with "use client" directive.
- The error is consistent.
- did rm -rf node_modules & npm install
Answered by gin
what u could do is using server-only npm i server-only and placing this at the top of your file where u use child_process
View full answer

8 Replies

what u could do is using server-only npm i server-only and placing this at the top of your file where u use child_process
Answer
@gin yes ur component is marked with use client thats good
OcicatOP
that helped me understand more the server-only package, thanks
@Ocicat that helped me understand more the server-only package, thanks
u can mark my answer as solution :)
@gin u can mark my answer as solution :)
OcicatOP
I would mark it, but I don't see an option for that. Is it a specific emoji?
like this ->
@gin like this ->
OcicatOP
TIL, thanks