react-dat-gui
react-dat-gui copied to clipboard
NextJS Server Error
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 />
.
Would probably need a codesandbox or something to see what is going on here, the package does have a main
property
This module is not transpiled so you need to use next-transpile-modules in your next.config.js.
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/
Confirmed @jamieowen PR works.