Does anyone get this error? I have had this problem for a while now and I’m not sure how to resolve it: ``` ╰─ sudo npm install -g @sanity/cli Password: /usr/local/bin/sanity...

2 replies
Last updated: Jan 13, 2021
Does anyone get this error? I have had this problem for a while now and I’m not sure how to resolve it:


╰─ sudo npm install -g @sanity/cli
Password:
  /usr/local/bin/sanity -> /usr/local/lib/node_modules/@sanity/cli/bin/sanity
+ @sanity/cli@2.1.4
updated 1 package in 0.774s


╭─────────────────────────────────────────────────────────────────╮
│                                                                 │
│      New patch version of npm available! 6.14.8 → 6.14.11       │
│   Changelog: <https://github.com/npm/cli/releases/tag/v6.14.11>   │
│                Run npm install -g npm to update!                │
│                                                                 │
╰─────────────────────────────────────────────────────────────────╯

╭─ (anaconda3)  ~/dev/<removed>/cms   master ● ⍟4                                                                            ✔  4788  10:16:08
╰─ sanity upgrade
@sanity/core not installed in current project
Project-specific commands not available until you run `sanity install`
⠙ Resolving dependencies^C
╭─ (anaconda3)  ~/dev/<removed>/cms   master ● ⍟4                                                                  SIGINT(2) ↵  4789  10:16:25
╰─ sanity install

✔ Saved lockfile
✖ Resolving dependencies
✖ Command failed with exit code 1.
✖ Resolving dependencies

Error: Command failed :(
  at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:3260:2554

AI Update

I've seen this issue before! You're running @sanity/cli@2.1.4, which is Sanity v2 - a significantly older version. The error during sanity install suggests dependency resolution problems, which can happen with older Sanity versions when combined with modern Node.js/npm versions or environment conflicts.

Immediate troubleshooting steps:

  1. Check your Node.js version:

    node -v

    The version compatibility is crucial here. Sanity v2 was built for older Node.js versions, while Sanity Studio v4 requires Node.js 20+. If you're on a very recent Node version, this could cause dependency resolution failures with v2 packages that weren't designed for it.

  2. Address the Anaconda environment: I notice (anaconda3) in your terminal prompt. Conda environments can interfere with npm's dependency resolution because they modify PATH and can introduce conflicting binaries:

    conda deactivate
    sanity install
  3. Clear caches and lockfiles:

    rm -rf node_modules
    rm package-lock.json
    rm yarn.lock  # if it exists
    npm cache clean --force
    sanity install
  4. Update npm: Your output shows npm 6.14.8 with an available update to 6.14.11. While this might not be the root cause, updating could help:

    npm install -g npm
  5. Check your package.json: Look at the dependencies in your package.json file. Sometimes v2 projects have dependency version conflicts that need manual resolution.

The bigger picture - consider upgrading:

Since you're on v2 (from 2020-2021 era), you're likely hitting compatibility issues because the npm ecosystem has evolved significantly. Old dependency trees can fail to resolve with modern package managers and Node versions.

I'd strongly recommend upgrading to Sanity Studio v4. While it requires Node.js 20+, you'll get:

  • Modern dependency resolution that works with current tooling
  • Active support and security updates
  • Better performance and developer experience
  • Access to features like Live Content API, Functions, and Content Releases

If you need to stay on v2 temporarily:

Try checking if there's a specific package causing the failure by looking at your package.json dependencies. You might also try using an older Node.js version via nvm to match what v2 was originally built against - typically Node 12-16 era.

What Node.js version are you running? That info would help narrow down the issue further. Also, the Anaconda environment is my top suspect here - try deactivating it first before other troubleshooting.

Ok, I feel silly now. After I deleted the folders
node_modules
,
dist
and the file
package-lock.json
the install command worked without problems.
Thanks for sharing the solution, Thomas 🙌 Glad you could fix it that way!

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?