Skip to content
This repository has been archived by the owner on May 15, 2022. It is now read-only.

NextJS Server Error #61

Open
robksawyer opened this issue Aug 3, 2020 · 4 comments
Open

NextJS Server Error #61

robksawyer opened this issue Aug 3, 2020 · 4 comments

Comments

@robksawyer
Copy link

robksawyer commented Aug 3, 2020

I'm getting the following error when running this in NextJS. I'm using the following config.

Server Error
Error: No "exports" main resolved in /Users/.../node_modules/react-dat-gui/package.json
This error happened while generating the page. Any console logs will be displayed in the terminal window.
const Controls = () => {
  const state = {
    data: {
      package: 'react-dat-gui',
      cameraRotationX: 0.6,
    },
  }

  const [data, setData] = useState(state)

  // Update current state with changes from controls
  const handleUpdate = (newData) => {
    console.log('newData', newData)
    setData((prevState) => ({
      data: { ...prevState.data, ...newData },
    }))
  }

  console.log('data', data)

  return (
    <DatGui
      data={data}
      onUpdate={handleUpdate}
      className="react-dat-gui-relative-position"
    >
      <DatNumber
        path="cameraRotationX"
        label="Number"
        min={-100}
        max={100}
        step={0.1}
      />
    </DatGui>
  )
}

And then in my main React component, just calling <Controls />.

@rohan-deshpande
Copy link
Collaborator

Would probably need a codesandbox or something to see what is going on here, the package does have a main property

@yatsyk
Copy link

yatsyk commented Nov 16, 2020

This module is not transpiled so you need to use next-transpile-modules in your next.config.js.

@jamieowen
Copy link

jamieowen commented Nov 18, 2020

I have transpiled modules setup but it still fails.

Removing exports in the package.json works for me. But if it's required then exports expects a string not a boolean.

This pull request is correct: #62

https://webpack.js.org/guides/package-exports/

@stevengrimaldo
Copy link

Confirmed @jamieowen PR works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants