sanity-io/client

Webpack error with expo

RickyAvina opened this issue · 5 comments

Describe the bug

Trying to launch project in web browser using Sanity and React-Native. However, I'm coming across these errors:

./node_modules/@sanity/client/dist/sanityClient.browser.mjs 2569:2-13
Can't import the named export 'jsonRequest' from non EcmaScript module (only default export is available)
./node_modules/@sanity/client/dist/sanityClient.browser.mjs 2570:2-14
Can't import the named export 'jsonResponse' from non EcmaScript module (only default export is available)
./node_modules/@sanity/client/dist/sanityClient.browser.mjs 2573:2-13
Can't import the named export 'observable' from non EcmaScript module (only default export is available)
./node_modules/@sanity/client/dist/sanityClient.browser.mjs 2571:2-10
Can't import the named export 'progress' from non EcmaScript module (only default export is available)

To Reproduce

  1. Create React Native project
  2. Install Sanity using npm i sanity
  3. Launch expo using expo start
  4. Launch web browser project with w

Expected behavior

A web browser with your React Native project should appear.

Screenshots
If applicable, add screenshots to help explain your problem.

Which versions of Sanity are you using?
locally:

@sanity/cli (global)  3.2.4 (up to date)
@sanity/image-url     1.0.2 (up to date)

In my package-lock.json
"@sanity/client": "version": "4.0.1"

What operating system are you using?
Mac OSX Ventura 13.0

Which versions of Node.js / npm are you running?

Run npm -v && node -v in the terminal and copy-paste the result here.

8.15.0
v16.17.1

I'm seeing the same issue with 4.0.1 but with a vanilla React app

Seeing the following with @sanity/client in vanilla Create React App:

./node_modules/@sanity/client/dist/sanityClient.browser.mjs
Can't import the named export 'jsonRequest' from non EcmaScript module (only default export is available)

Hi, could you try with npm i @sanity/client@^5.0.0 to see if it resolves it?

looks like this fixed it, thanks!!

Perfect! 😌