Reputation: 53
I am using "npm install -g @sanity/cli sanity init --coupon javascriptmastery2022" everything is workig well until I want to fetch the data from sanity client it says: ***Module not found: Can't resolve '@sanity/client'
1 | import sanityClient from '@sanity/client'; 2 | import imageUrlBuilder from '@sanity/image-url';*** and have checked the package json file and saw there is no '@sanity/client' installed there. then I run npm install -g @sanity/client and npm command works but there is no '@sanity/client' found in the package json, and the error is still the same
I really appreciate if anyone can help me
Upvotes: 4
Views: 7765
Reputation: 1
I got this error recently, I went on sanity doc, to check for @sanity/client, and there you will see the npm install package (npm install -g @sanity/client)
this works as well-------> "npm i @sanity/client"
if this does work, just use "--force" so " npm i @sanity/client --force ", and install in the root folder not the sanity_ecommerce folder, also check the package.json in the root folder to see if it is there.
Upvotes: 0
Reputation: 1
I also stumbled into this error while following the exact same tutorial.
Simply install image-url to your project:
npm install --save @sanity/image-url
Upvotes: 0