#Running dev servers programmatically

12 messages · Page 1 of 1 (latest)

golden breach
#

Hi everyone,

I'm trying to create a dev server programmatically using next, eg:

const app = next({ dev, hostname, port, dir });

However, I'm having a lot of trouble.

1- For whatever reason, I'm forced to add experimental.appDir in the next.config.js file of the directory the server is serving, even though, running next dev directly from the terminal suggests not to add that option.

2- After starting the server, none of the fonts/styles are being loaded, and the console spits out these errors: (see screenshots)
It almost feels like next is running an older version of dev server when launching it programmatically.

3- this is more a nice to have, but is there any way I can tell next to use turbopack when starting the server?

Is there a different configuration that applies to dev servers launch in this way? any help is appreciated!

PS: I'm very to new to next.js, so please bear with me in case this is obvious!

cold patrolBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

still mountain
#

can you try updating your next.js version

#

wait you say error is not when normaly run

#

ahhh, i didn't even know you could programicly launch it without using cli (ie process.spawn)

golden breach
#

You can, but It's not great, and I'm having trouble finding resources regarding this

still mountain
#

but whats wrong with using npm scripts and putting the turbo flag there?

golden breach
#

I'm building an app for which I need to run headless dev servers

still mountain
#

headless dev server?

golden breach
#

I'm writing a script that expects a next app directory path, spins up a dev server for it, and returns the url the server is running on

still mountain
#

hmmm

golden breach
#

The app is essentially a no-code editor. the editor generates next.js code.