Next.js Experimental https Error on Windows

Next.js Experimental https Error on Windows

Error

  • 執行 npm run dev 時,發生以下錯誤
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
> projectname@0.0.1 dev
> next dev -p 3000 --experimental-https

  Self-signed certificates are currently an experimental feature, use at your own risk.
   Attempting to generate self signed certificate. This may prompt for your password
  Failed to generate self-signed certificate. Falling back to http. Error: Command failed: "mkcert-v1.4.4-windows-amd64.exe" -install -key-file "projectname\certificates\localhost-key.pem" -cert-file "projectname\certificates\localhost.pem" localhost 127.0.0.1 ::1
    at checkExecSyncError (node:child_process:890:11)
    at execSync (node:child_process:962:15)
    at createSelfSignedCertificate (projectname\node_modules\next\dist\lib\mkcert.js:122:37)
    at async runDevServer (projectname\node_modules\next\dist\cli\next-dev.js:293:35)
    at async nextDev (projectname\node_modules\next\dist\cli\next-dev.js:308:5)
    at async main (projectname\node_modules\next\dist\bin\next:155:5) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 2436,
  stdout: null,
  stderr: null
}
    Next.js 14.1.4
   - Local:        http://localhost:3000

  Ready in 2.3s

Solution

  • 以 “系統管理員” 開啟 Powershell 至專案目錄,再次執行 npm run dev
  • 僅需處理一次,之後可使用 IDE 執行專案
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus