Home FAQ - How to mark NX libraries relevant for remix server
Post
Cancel

FAQ - How to mark NX libraries relevant for remix server

Problem

When a library in NX is created, it is sometimes relevant only for the Remix server. The Remix framework cannot tree-shake the server and client parts of NX libraries automatically.

When this happens, the Remix server libs are bundled into the client code which is meant only for the browser. Thus the following cryptic error occurs:

1
TypeError: Cannot read properties of undefined (reading 'root')

Solution

Add the following line to the package.json file of your NX library which only runs on the server

1
2
3
4
5
{
  ...
  "sideEffects": true;
}

References:

This post is licensed under CC BY 4.0 by the author.