'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



Solution 1:[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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sodapopjam