Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🤠 July 18th

Next.js eCommerce Starter - npm ERR!

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
vercel.com 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) — <https://vercel.com/feedback>
> NOTE: Requested port 3000 is already in use
> NOTE: Requested port 3001 is already in use
> Running Dev Command "npm run dev"

> sanity-template-nextjs-ecommerce@1.0.0 dev /home/hussamkhatib/projects/e-commerce
> concurrently "next --port $PORT" "cd studio && 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 && 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>
> 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 && sanity start\"",
    "build": "echo 'Building Sanity to public/studio…' && cd studio && sanity build ../public/studio -y && cd .. && 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

Sanity is a 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.

Was this answer helpful?