What is the difference between yarn and npm?

3 replies
Last updated: Feb 9, 2021
Is there a difference between
sanity install @sanity/color-input
and
npm install @sanity/color-input
? is sanity install just a alias for yarn or we actually need to install dependencies through
sanity install
?
AI Update

Good question! There's actually an important difference between Sanity Studio v2 and v3 here.

In Sanity Studio v3 (current version)

sanity install is deprecated and no longer needed. You should use your regular package manager directly:

npm install @sanity/color-input
# or
yarn add @sanity/color-input
# or
pnpm add @sanity/color-input

In v3, plugins are just regular npm packages that you install and then add to your sanity.config.ts file manually. There's no special sanity install command functionality.

In Sanity Studio v2 (legacy)

sanity install was not just an alias - it actually did two things:

  1. Installed the package (using npm or yarn under the hood, depending on what you had)
  2. Automatically added the plugin to your sanity.json config file

So sanity install @sanity/color-input would both install the package AND add it to the plugins array in your sanity.json configuration file. This was a convenience feature of the v2 CLI that automated the two-step process.

Why the change?

In v3, Sanity moved away from the CLI managing your config automatically. The modern approach gives you more control - you manually import and configure plugins in your sanity.config.ts file:

import {defineConfig} from 'sanity'
import {colorInput} from '@sanity/color-input'

export default defineConfig({
  // ... other config
  plugins: [colorInput()]
})

This aligns with modern JavaScript tooling practices and gives you better type safety and IDE support.

Bottom line: If you're on Studio v3 (which you should be, as v2 is deprecated), just use npm install or your preferred package manager. The sanity install command is deprecated and you don't need it anymore - just install the package and manually add it to your config file.

sanity install
also adds it to the
plugins
array of
sanity.json
. Apart from that there's no real difference between installing with yarn yourself
You just saved me a bit of “why isn’t sanity color input working” stackoverflow! Thanks Espen!
Happy to help!

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?