You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SvelteKit无法执行npm run start及生产Node服务器启动方式咨询

解决SvelteKit生产环境Node服务器启动问题

Hey there! Let's walk through how to get your production Node server up and running, and touch on your earlier note too.

First, kudos on fixing the config.kit.adapter issue by installing @sveltejs/adapter-node@next—it’s super frustrating when tooling updates outpace documentation, so I totally get your wish for more timely docs.

Now, onto your current problem with npm run start: The reason you’re seeing that preview message is that recent SvelteKit updates changed the default start script to point to svelte-kit preview, which is only meant for local checks of your production build, not actual production use. Here’s how to properly launch your production Node server:

  • Step 1: Build your production bundle
    First, make sure you’ve compiled your project for production. Run this command:

    npm run build
    

    This uses the adapter-node you installed to generate a production-ready Node.js bundle, which will be saved in the build directory by default.

  • Step 2: Launch the production server
    Instead of relying on the default start script, run the entry point of your built bundle directly:

    node build/index.js
    
  • Step 3: Update your package.json (optional but recommended)
    To get npm run start working like it did before, edit your package.json’s scripts section to point to the built Node file instead of the preview command. It should look something like this:

    "scripts": {
      "dev": "svelte-kit dev",
      "build": "svelte-kit build",
      "start": "node build/index.js",
      "preview": "svelte-kit preview"
    }
    

    Now, when you run npm run start, it’ll launch your actual production Node server, not just a preview.

That should get you up and running properly in production.

内容的提问来源于stack exchange,提问作者Martin Weissenboeck

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 16:03:10