Closed alexhochreiter closed 3 years ago
Had similar issues in Vulcan and I scratched my head on this. Maybe check https://github.com/VulcanJS/vulcan-npm/blob/devel/scripts/link-duplicates.sh and https://github.com/VulcanJS/vulcan-next/blob/devel/scripts/link-vulcan.sh.
Basically in this case I also link "react" and "react-dom" (don't forget to always check both when doing yarn why
). They are also peer dependencies, so theoretically this should not be a problem, but I don't really get how this work internally.
Since I still need to install react
to test by NPM packages, it seems to be the version used by them instead of the Next project version => leads to bugs.
With those scripts I don't have problems anymore, I just run them at install first in the NPM monorepo then in the Next app.
What version of Next.js are you using?
10.0.4
What version of Node.js are you using?
v14.15.1
What browser are you using?
All
What operating system are you using?
Fedora Workstation 33
How are you deploying your application?
I cannot
Describe the Bug
I am using a wrapper to streamline my page structures across different projects, which utilizes nextjs's custom server. Yet the wrapper fails with "Error: Invalid hook call." when trying to render anything. I checked if different versions of
react
orreact-dom
are installed.npm ls react
saysreact@17.0.1
is the only version installed.resulting error stack:
Expected Behavior
expected to serve a minimal example page without problems - doesnt matter if implemented as hook or not (the error message is the same in both cases)
To Reproduce
create two (empty) projects:
my-nextjswrapper-lib
my-app
contents of
my-nextjswrapper-lib/package.json
contents of
my-nextjswrapper-lib/index.js
contents of
my-app/package.json
contents of
my-app/index.js
contents of
my-app/pages/hello.js
To test locally, go to the my
my-nextjswrapper-lib
dir and executenpm link
. Then go to themy-app
dir and executenpm i
thennpm link my-nextjswrapper-lib
. Start the server from themy-app
dir withnode index.js
and openlocalhost:8000/hello
from any browser.