Skip to content

Can't import the named export 'jsonRequest' from non EcmaScript module (only default export is available) #40

@ghaithAlMasri

Description

@ghaithAlMasri

Hello i am receiving this error:


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

here is my client.js:


import SanityClient from '@sanity/client';
import imageUrlBuilder from '@sanity/image-url';

export const client = SanityClient({
    projectId: process.env.REACT_APP_SANITY_PROJECT_ID,
    dataset: 'production',
    apiVersion:'2021-10-21',
    useCdn: false,
    token: process.env.NEXT_PUBLIC_SANITY_TOKEN,
});

const builder = imageUrlBuilder(client);

export const urlFor = (source) => builder.image(source);


whenever this export is imported in any file i get this error.

import {client} from '../client'

i have tried sanityClient, SanityClient and createClient all resulting in the same issue.

finally here is my package.json and a screenshot of the manager on sanity:

{
  "name": "excuse_frontend",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@react-oauth/google": "^0.7.0",
    "@sanity/client": "^4.0.1",
    "@sanity/image-url": "^1.0.2",
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "axios": "^1.3.3",
    "jwt-decode": "^3.1.2",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-icons": "^4.7.1",
    "react-loader-spinner": "^5.3.4",
    "react-masonry-css": "^1.0.16",
    "react-router-dom": "^6.8.1",
    "react-scripts": "^2.1.3",
    "uuid": "^9.0.0",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "tailwindcss": "^3.2.6"
  }
}

Screenshot 2023-02-14 at 3 43 54 AM

Any solutions? I can't find any proper solutions online.
Much appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions