I created a Next.Js app with create-next-app and trying to import and use ramda. But it gives me next error TypeError: Cannot read properties of undefined (reading 'add'). So actual import from lib is undefined.
But if I replace ramda.add with lodash.add – all works fine. Do somebody know what is the difference and how I make it work with ramda?
My setup
"lodash": "^4.17.21",
"next": "13.0.5",
"ramda": "^0.28.0",
"typescript": "4.9.3"
"packageManager": "yarn@3.3.0",
I would expect it work with both libs, as for me there’s no difference in usage.
I tried to move it to getServerSideProps, use yarn v1, npm, recreate a project..
>Solution :
See https://ramdajs.com/ docs:
Note for versions > 0.25 Ramda versions > 0.25 don’t have a default export. So instead of import R from ‘ramda’;, one has to use import * as R from ‘ramda’; Or better yet, import only the required functions via import { functionName } from ‘ramda’;
So you have to use
import * as R from 'ramda';