My project using next.js ecommerce starter is not running locally
6 replies
Last updated: Feb 2, 2021
U
i have created a project using next.js ecommerce starter.I am not able to run it locally.
steps i followed.
vercel.com to
used
steps i followed.
vercel env pullto rename .env filechanged delevelopment command in
vercel.com to
npm run dev
used
npm startto 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! code ELIFECYCLE 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
A
hi
user U
- looks like you might need to install the vercel tooling on local?Jan 28, 2021, 5:12 AM
U
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] [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
U
.env file
# Created by Vercel CLI VERCEL="1" VERCEL_ENV="development" VERCEL_URL="" VERCEL_GIT_PROVIDER="" VERCEL_GIT_REPO_SLUG="" VERCEL_GIT_REPO_OWNER="" VERCEL_GIT_REPO_ID="" VERCEL_GIT_COMMIT_REF="" VERCEL_GIT_COMMIT_SHA="" VERCEL_GIT_COMMIT_MESSAGE="" VERCEL_GIT_COMMIT_AUTHOR_LOGIN="" VERCEL_GIT_COMMIT_AUTHOR_NAME="" NEXT_PUBLIC_SANITY_DATASET="production" SANITY_STUDIO_API_DATASET="production" SANITY_STUDIO_API_PROJECT_ID="${the_id}" NEXT_PUBLIC_SANITY_PROJECT_ID="${the_id}"
Jan 28, 2021, 12:46 PM
U
the scripts from package.json(root dir)
do let me know if the information is sufficient for answering
"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" },
Jan 28, 2021, 12:47 PM
T
A couple thoughts on what's happening:
So what should happen (and looks like might not be...?) is that when you run
Other possibility, the dev script may not be properly moving into 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
So what should happen (and looks like might not be...?) is that when you run
npm installit should install all the dependencies for the root folder (your Next.js frontend). Once that's done, NPM should be automatically running the
postinstallscript, which will use Lerna to run npm install for the Sanity Studio in the
/studiofolder. That's one possibility. If that's what's breaking, the fix would be to run
npm run postinstalland that should install the rest of what's necessary.
Other possibility, the dev script may not be properly moving into the
/studiofolder and may be trying to run
sanity startinside the root, which technically isn't the studio application, so it's failing. If the above solution doesn't work, try running
npm startin your root directory, and in another terminal window, run
sanity startinside the
/studiofolder.
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
U
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.