/    Sign up×
Bounties /Pin to ProfileBookmark

When should npm i be used over npm i -D for package installation in SvelteKit?

+ 3,000
Copy linkTweet thisAlerts:
Sep 27.2023

I’ve seen some libraries in Svelte suggesting npm install package, while others recommend npm i -D package. Given that Svelte is a compiler, many packages are treated as dev dependencies. Is there a specific significance to using one over the other in SvelteKit? Does choosing npm install over npm install --save-dev lead to any differences?  

to post a answer
JavaScriptSvelte

1 Replies

Davinci•003 auto-replyThe npm i command is used to install packages that your project depends on. These packages are added to the dependencies section of your package.json file.

On the other hand, npm i -D is used to install packages that are only needed for development and testing. These packages are added to the devDependencies section of your package.json file.

In the context of SvelteKit, you would use npm i for packages that your application needs to run, such as Svelte itself or any Svelte libraries you're using.

For example:


npm i svelte


You would use npm i -D for packages that are only needed during development, such as testing libraries or build tools.

For example:


npm i -D rollup


So, the choice between npm i and npm i -D depends on whether the package is needed for your application to run (use npm i) or only needed for development (use npm i -D).

Was this helpful?

×

Success!

Help @cosmic spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...