Watch a live product demo 👀 See how Sanity powers richer commerce experiences

My project using next.js ecommerce starter is not running locally

6 replies
Last updated: Feb 2, 2021
i have created a project using next.js ecommerce starter.I am not able to run it locally.
steps i followed.

vercel env pull
to rename .env filechanged delevelopment command in to
npm run dev

npm start
to start developement server which gives error

~/projects/e-commerce$ npm start

> sanity-template-nextjs-ecommerce@1.0.0 start /home/hussamkhatib/projects/e-commerce
> vercel dev

sh: 1: vercel: not found
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! sanity-template-nextjs-ecommerce@1.0.0 start: `vercel dev`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the sanity-template-nextjs-ecommerce@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/hussamkhatib/.npm/_logs/2021-01-28T04_47_29_680Z-debug.log

Jan 28, 2021, 4:59 AM
user U
- looks like you might need to install the vercel tooling on local?
Jan 28, 2021, 5:12 AM
tried that ,i'm getting more errors
hussamkhatib@hussamkhatib-VPCEB44EA:~/projects/e-commerce$ npm start

> sanity-template-nextjs-ecommerce@1.0.0 start /home/hussamkhatib/projects/e-commerce
> vercel dev

Vercel CLI 21.2.1 dev (beta) — <>
&gt; NOTE: Requested port 3000 is already in use
&gt; NOTE: Requested port 3001 is already in use
&gt; Running Dev Command "npm run dev"

&gt; sanity-template-nextjs-ecommerce@1.0.0 dev /home/hussamkhatib/projects/e-commerce
&gt; concurrently "next --port $PORT" "cd studio &amp;&amp; sanity start"

[1] @sanity/core not installed in current project
[1] Project-specific commands not available until you run `sanity install`
[1] Error: "start" is not available outside of a Sanity project context.
[1] Run the command again within a Sanity project directory, where "@sanity/core"
[1] is installed as a dependency.
[1]     at D.runCommand (~/projects/e-commerce/node_modules/@sanity/cli/bin/sanity-cli.js:3254:1345)
[1]     at t.exports (~/projects/e-commerce/node_modules/@sanity/cli/bin/sanity-cli.js:1788:2295)
[1] cd studio &amp;&amp; sanity start exited with code 1
[0] Browserslist: caniuse-lite is outdated. Please run:
[0] npx browserslist@latest --update-db
[0] Loaded env from /home/hussamkhatib/projects/e-commerce/.env
[0] ready - started server on <http://localhost:3002>
&gt; Ready! Available at <http://localhost:3002>
[0] event - compiled successfully

Jan 28, 2021, 12:45 PM
.env file
# Created by Vercel CLI

Jan 28, 2021, 12:46 PM
the scripts from package.json(root dir)
  "scripts": {
    "dev": "concurrently \"next --port $PORT\" \"cd studio &amp;&amp; sanity start\"",
    "build": "echo 'Building Sanity to public/studio…' &amp;&amp; cd studio &amp;&amp; sanity build ../public/studio -y &amp;&amp; cd .. &amp;&amp; next build",
    "start": "vercel dev",
    "postinstall": "lerna bootstrap",
    "check-template": "sanity-template check"
do let me know if the information is sufficient for answering
Jan 28, 2021, 12:47 PM
A couple thoughts on what's happening:
So what should happen (and looks like might not be...?) is that when you run
npm install
it should install all the dependencies for the root folder (your Next.js frontend). Once that's done, NPM should be automatically running the
script, which will use Lerna to run npm install for the Sanity Studio in the
folder. That's one possibility. If that's what's breaking, the fix would be to run
npm run postinstall
and that should install the rest of what's necessary.
Other possibility, the dev script may not be properly moving into the
folder and may be trying to run
sanity start
inside the root, which technically isn't the studio application, so it's failing. If the above solution doesn't work, try running
npm start
in your root directory, and in another terminal window, run
sanity start
inside the
If either of those things are happening, it's something we'll want to look into fixing with the starter's scripts, but hopefully one of those solutions will get you running
Jan 28, 2021, 2:09 PM
oh yes ! ,such a silly mistake my me . i forgot to run
npm run
.finally i can see my studio working too
Feb 2, 2021, 4:56 PM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
After adding the subtitle and running this code npm run graphql-deploy It does nothingSep 15, 2020
how to limit a reference to just one entry in Studio reference input side versus the default as-many-entries-as-you-fill-in-an-array...Sep 18, 2020
Is it possible to fetch more than one "_type" using GROQ?Nov 2, 2020
I want to add a view with the Structure builder (S.view.component) where I list similar documents based on the title. What...Sep 23, 2020
Is there a structure builder example where the format of each preview for the document list is modified?Feb 3, 2021
I have an array of references to a country schema type but it always just returns NULL values for meJan 30, 2021
Hi, I need help with a query for getting the url of an image asset. Here is what I've been trying, but I only get the _ref...Dec 1, 2020
Sanity UI looks brilliant :smiley: Is something like the current date picker possible at the moment? I’m not sure if anicon...Dec 21, 2020
Hey everyone. I have been coding and may have potentially accidentally deleted something. Does anyone know how to resolve...Dec 26, 2020
Hello everyone and happy new year :raised_hands::skin-tone-2:, I have a problem with outputting Portable Text :disappointed:...Jan 1, 2021

Related contributions

Clean Next.js + Sanity app
- Template

Official(made by Sanity team)

A clean example of Next.js with embedded Sanity ready for recomposition.

Cody Olsen
Go to Clean Next.js + Sanity app

Blog with Built-in Content Editing
- Template

Official(made by Sanity team)

A Sanity-powered blog with built-in content editing and instant previews.

Go to Blog with Built-in Content Editing