Mahdi Ehssani
Mahdi Ehssani

Reputation: 53

Module not found: Can't resolve '@sanity/client' > 1 | import sanityClient from '@sanity/client';

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

Answers (4)

DOJ
DOJ

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

just use --force to install npm package

Upvotes: 1

sodapopjam
sodapopjam

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

Mahfujur51
Mahfujur51

Reputation: 72

Please Install npm i @sanity/client

I think it should be solve

Upvotes: 2

Related Questions