What's the best way to start Svelte app on production server?
Asked Answered
E

1

7

I'm using SvelteKit (1.0.0) with the node adapter.

I want to use it on my server and start it with pm2.

What's the best way of starting a Svelte app with a node adapter without npm start?

I don't need pm2 command, just an npm command for Svelte.

Enabling answered 5/4, 2021 at 22:20 Comment(0)
R
10
node build/index.js  # Start production server

Full example:

npm init svelte@next # Initialize project
npm install          # Install dependencies
npm run build        # Build production version
node build/index.js  # Start production server
Rb answered 10/4, 2021 at 10:9 Comment(4)
Thank you! I'm getting 2 rows when I run pm2 start node build/index.js --name Example. Am I doing something wrong? What script do you recommend?Enabling
@Ulvi: Sorry, I'm not familiar with pm2 and I don't know what "2 rows" means.Rb
Thank you @Leftium! As a JS/Svelte/SvelteKit-beginner I was always wondering, what "serving your app" after running npm run build meant. Your post has shed a lot of light into my head :-).Unaccomplished
@Enabling for next runs you just need to type pm2 start Example but before that you need to remove your previously duplicates by pm2 remove Example.Infer

© 2022 - 2024 — McMap. All rights reserved.