Double server from CLI
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Pro
Binaries:
Node: 16.15.1
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 12.2.1-canary.1
eslint-config-next: 12.2.0
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
CLI
Describe the Bug
I have app.js
file in root folder.
const start = require('next/dist/cli/next-start')
start.nextStart()
It starts 2 servers at the same time. It starts dev server instead of production and overwrites contents of .next
folder with files of dev server.
> node app.js
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
Accessing localhost:3000 returns error 404
Expected Behavior
Only start production server
Link to reproduction
https://github.com/Arctomachine/reproduction-double-server
To Reproduce
- Run
next build
- Run
node app.js
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Running multiple servers in a single command terminal instance
Each folder requires me to run a different command to run it's server in a separate command instance which is troublesome for my...
Read more >Ssh through two servers and a user in one command line
How to go about doing in one command line the following operations? $ ssh server-one $ su - user $ ssh server-two. Of...
Read more >Run two servers simultanually from bash script - Ask Ubuntu
and I executed using bash script.sh . Now hueserver is running but not hiveserver. A second terminal is open but with nothing in...
Read more >5.8.2.1 Starting Multiple MySQL Instances at the Windows ...
Each server starts in the foreground (no new prompt appears until the server exits later), so you need to issue those two commands...
Read more >Setting multiple network time servers from the command line
Add the secondary time server as the second line in /etc/ntp.conf echo "server $TimeServer2" >> /etc/ntp.conf. # Add the tertiary time ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I searched a bit and the issue first appeared in version 12.1.1-canary.5.
Importing
next/dist/cli/next-start
without callingnextStart()
before this version does not start the server.edit: It’s a regression from https://github.com/vercel/next.js/pull/34836:
When
getProjectDir
is called, it now also importsnext/bin/next.ts
, which is itself callingcommands[command]()
.This
command
should not be defined, but it fallbacks todefaultCommand
, which isdev
(that explains why the dev server is also started)2nd edit: Opened a PR that fixes the issue: #38274
require('next/dist/cli/next-start')
alone already starts server and gives one output. If you try only this line, you will get fully working dev server. But in either case, with 2 outputs it starts malfunctioning dev server, while functioning production is expected.