react-dat-gui icon indicating copy to clipboard operation
react-dat-gui copied to clipboard

NextJS Server Error

Open robksawyer opened this issue 3 years ago • 4 comments

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 />.

robksawyer avatar Aug 03 '20 18:08 robksawyer

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

rohan-deshpande avatar Aug 04 '20 06:08 rohan-deshpande

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

yatsyk avatar Nov 16 '20 14:11 yatsyk

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/

jamieowen avatar Nov 18 '20 19:11 jamieowen

Confirmed @jamieowen PR works.

stevengrimaldo avatar Mar 29 '21 22:03 stevengrimaldo