0

So, I have an npm package that requires React that I'm wanting to test locally by using npm link to import it into its consumer React app. The typical way (and in fact the way proposed in the React docs) to avoid getting an Invalid hook call error is to use npm link with the react and react-dom directories in node_modules. This works using an older version of Node and npm but it seems like it doesn't work after around version 7 of npm? Attempting to perform npm links with these directories always seems to result in error like this:

63 verbose stack TypeError: Cannot set properties of null (setting 'dev')
63 verbose stack     at calcDepFlagsStep (C:\Users\some_user\AppData\Roaming\nvm\v18.12.0\node_modules\npm\node_modules\@npmcli\arborist\lib\calc-dep-flags.js:34:21)
63 verbose stack     at visit (C:\Users\some_user\AppData\Roaming\nvm\v18.12.0\node_modules\npm\node_modules\@npmcli\arborist\lib\calc-dep-flags.js:12:20)
63 verbose stack     at visitNode (C:\Users\some_user\AppData\Roaming\nvm\v18.12.0\node_modules\npm\node_modules\treeverse\lib\depth-descent.js:58:25)
63 verbose stack     at next (C:\Users\some_user\AppData\Roaming\nvm\v18.12.0\node_modules\npm\node_modules\treeverse\lib\depth-descent.js:44:19)
63 verbose stack     at depth (C:\Users\some_user\AppData\Roaming\nvm\v18.12.0\node_modules\npm\node_modules\treeverse\lib\depth-descent.js:83:10)
63 verbose stack     at depth (C:\Users\some_user\AppData\Roaming\nvm\v18.12.0\node_modules\npm\node_modules\treeverse\lib\depth.js:27:12)
63 verbose stack     at calcDepFlags (C:\Users\some_user\AppData\Roaming\nvm\v18.12.0\node_modules\npm\node_modules\@npmcli\arborist\lib\calc-dep-flags.js:10:15)
63 verbose stack     at [copyIdealToActual] (C:\Users\some_user\AppData\Roaming\nvm\v18.12.0\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:1509:7)
63 verbose stack     at Arborist.reify (C:\Users\some_user\AppData\Roaming\nvm\v18.12.0\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:157:35)
63 verbose stack     at async Link.linkInstall (C:\Users\some_user\AppData\Roaming\nvm\v18.12.0\node_modules\npm\lib\commands\link.js:85:7)

Is this actually just a bug with newer npm? Thanks!

RobSka17
  • 41
  • 3

0 Answers0