未找到模块:无法解析“@sanity/client” > 1 |从“@sanity/client”导入 sanityClient;

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

我正在使用“npm install -g @sanity/cli sanity init --coupon javascriptmastery2022" 一切正常,直到我想从 sanity 客户端获取数据,它说: ***找不到模块:无法解析 '@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

如果有人能帮助我,我将不胜感激

请安装npm i @sanity/client

我觉得应该可以解决

我在遵循完全相同的教程时也遇到了这个错误。

只需将 image-url 安装到您的项目:

npm install --save @sanity/image-url