Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with node_modules copy mode and next-js #163

Open
Radvendii opened this issue Jul 25, 2022 · 0 comments
Open

Problems with node_modules copy mode and next-js #163

Radvendii opened this issue Jul 25, 2022 · 0 comments

Comments

@Radvendii
Copy link

In the build function, we reference nm (the generated node_modules) in two ways. One is in buildInputs, and the other is by copying / symlinking it into the current directory in the preConfigure phase. Is there a reason we do both of these?

It seems to be causing problems when using next-js. It's also possible I am diagnosing the problem wrong; I am not very familiar with any of the pieces here.


The error I get is:

Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  • You might have mismatching versions of React and the renderer (such as React DOM)
  • You might be breaking the Rules of Hooks
  • You might have more than one copy of React in the same app See for tips about how to debug and fix this problem.

I think the relevant point is "You might have more than one copy of React in the same app." Since the copy it is finding in the error message is the one in the nix store, rather than in the current directory.

When I override as follows:

(pkgs.npmlock2nix.build {
  ...
}).overrideAttrs (old: {
  buildInputs = [ pkgs.nodejs ]; # note that the old contents of `buildInputs` (namely `nm`) is being overwritten
  preConfigure = old.preConfigure + ''
    chmod u+x node_modules/.bin/*
  '';
})

it works.

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

No branches or pull requests

1 participant