Next.js Discord

Discord Forum

Running CLI commands

Unanswered
Lesser White-fronted Goose posted this in #help-forum
Open in Discord
Lesser White-fronted GooseOP
Hi!

Hi!

We have quite a few scripts that we run using tsx in our Next JS app, these scripts imports some of our application code and have import "server-only"; imports and use import { cache } from 'react'; This unfortunately makes it impossible to run a script (unless we comment out the server only part temporarily) with tsx giving the following error:

Error: This module cannot be imported from a Client Component module. It should only be used from a Server Component.

I've tried following this suggestions: https://stackoverflow.com/a/78881358/2942212
TLDR
tsx --conditions=react-server your-code.ts

But to no luck, doing that results in this error instead Error: This entry point is not yet supported outside of experimental channels.

Does anyone have a solution for running scripts in a next JS app with react-server stuff?

0 Replies