sanity: Command failed with exit code 1 (EPERM): npx install-peerdeps --yarn next-sanity@9

Describe the bug

I’m encountering an issue while trying to initialize Sanity for a Next.js project. The install-peerdeps command fails with a permission error despite multiple attempts with different approaches. Here are the details:

To Reproduce

Steps to reproduce the behavior:

1.Install a next boilerplate git clone https://github.com/next-enterprise.git cd next-enterprise yarn install --frozen-lockfile

  1. Install sanity over the next project npx sanity@latest init --env --create-project "Next.js Live Preview" --dataset production

  2. Answering CLI questions like this :

  • Would you like to add configuration files for a Sanity project in this Next.js folder? Yes
  • Do you want to use TypeScript? Yes
  • Would you like an embedded Sanity Studio? Yes
  • What route do you want to use for the Studio? /studio
  • Select project template to use Clean project with no predefined schema types
  • Would you like to add the project ID and dataset to your .env file? Yes

Expected behavior

The command should init & install all necessary peer dependencies for sanity inside the existing nextjs project

Which versions of Sanity are you using?

sanity: command not found

What operating system are you using?

Distributor ID: Ubuntu Description: Ubuntu 22.04.4 LTS Release: 22.04 Codename: jammy

Which versions of Node.js / npm are you running?

Run npm -v && node -v in the terminal and copy-paste the result here.

npm 10.8.1 node v20.15.0

Additional context

This is the last lines of the console output :


install-peerdeps v3.0.3
Installing peerdeps for next-sanity@9.
yarn add next-sanity@9.4.2 @sanity/client@^6.20.1 @sanity/icons@^3.0.0 @sanity/types@^3.37.1 @sanity/ui@^2.0.11 next@^15.0.0 react@^19.0.0 sanity@^3.37.1 styled-components@^6.1

ERR undefined

Error: Command failed with exit code 1 (EPERM): npx install-peerdeps --yarn next-sanity@9
    at makeError$1 (~/.npm/_npx/7c099b67f9967cde/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:17897:32)
    at ~/.npm/_npx/7c099b67f9967cde/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:18238:29
    at async initSanity (~/.npm/_npx/7c099b67f9967cde/node_modules/@sanity/cli/lib/_chunks-cjs/cli.js:44389:110)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 6
  • Comments: 16 (4 by maintainers)

Most upvoted comments

for me, installing deps manually fixes the problem

yarn add next-sanity@9.5.0 next@^15.0.0 react@^19.0.0 sanity@^3.57.4 @sanity/ui@^2.8.9 @sanity/icons@^3.4.0 @sanity/types@^3.57.4 @sanity/client@^6.21.3 styled-components@^6.1

This was an issue on the install-peerdeps side, specifically for users of Yarn >1. I just pushed a fix which is live in the latest release, v3.0.6, that should resolve this issue.

Running into a similar problem.

Trying to port an exisiting next-js project to be using sanity. Have "next": "^14.2.3", in my package json

With yarn, running npx install-peerdeps --yarn next-sanity as mentioned on https://www.npmjs.com/package/next-sanity/v/4.1.5#yarn

Response:

install-peerdeps v3.0.3
Installing peerdeps for next-sanity@latest.
yarn add next-sanity@9.4.3 @sanity/client@^6.20.1 @sanity/icons@^3.0.0 @sanity/types@^3.37.1 @sanity/ui@^2.0.11 next@^15.0.0 react@^19.0.0 sanity@^3.37.1 styled-components@^6.1

ERR undefined

The undefined error makes it hard to triage. But I am guessing it trying to install next 15 in a next 14 project is probably part of the issue.