prismicio / prismic-react

React components and hooks to fetch and present Prismic content
https://prismic.io/docs/technologies/homepage-reactjs
Apache License 2.0
154 stars 40 forks source link

imgix-url-builder could not be resolved #123

Closed ghacosta closed 2 years ago

ghacosta commented 2 years ago

Versions

Reproduction

Additional Details

Steps to reproduce

npm install @prismicio/react @prismicio/client @prismicio/helpers

Create client according to docs (replacing repositoryName and accessToken):

import * as prismic from '@prismicio/client'

// Fill in your repository name
export const repositoryName = 'your-repo-name'
const endpoint = prismic.getEndpoint(repositoryName)

export const client = prismic.createClient(endpoint, {
  // If your repo is private, add an access token
  accessToken: '',

  // This defines how you will structure URL paths in your project.
  // Update the types to match the Custom Types in your project, and edit
  // the paths to match the routing in your project.
  //
  // If you are not using a router in your project, you can change this
  // to an empty array or remove the option entirely.
  routes: [
    {
      type: 'page',
      path: '/:uid',
    },
  ],
})

Registering Client:

import React from 'react'
import ReactDOM from 'react-dom'

import './index.css'
import App from './App'

import { PrismicProvider } from '@prismicio/react'
import { client } from './prismic'

ReactDOM.render(
  <React.StrictMode>
    <PrismicProvider client={client}>
      <App />
    </PrismicProvider>
  </React.StrictMode>,
  document.getElementById('root')
)

Perfomr Query:

import { PrismicRichText, useFirstPrismicDocument } from '@prismicio/react'

function App() {
  const [document] = useFirstPrismicDocument()

  return (
    <div>
      {document && (
        <PrismicRichText field={document.data.example_rich_text} />
      )}
    </div>
  )
}

What is expected?

To show the document

What is actually happening?

Getting this error while bundling:

While trying to resolve module `imgix-url-builder` from file `/Path/to/project/node_modules/@prismicio/helpers/dist/index.js`, the package `/Path/to/project/node_modules/imgix-url-builder/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Path/to/project/node_modules/imgix-url-builder/dist/index.cjs`. Indeed, none of these files exist:

  * /Path/to/project/node_modules/imgix-url-builder/dist/index.cjs(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
  * /Path/to/project/node_modules/imgix-url-builder/dist/index.cjs/index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
ghacosta commented 2 years ago

it was solved and closed here #->https://github.com/prismicio-community/imgix-url-builder/issues/1#issuecomment-1035359526