#Build Error When Referencing Local package that depends on node:crypto

1 messages · Page 1 of 1 (latest)

mild radish
#

Hi Folks, I moved some code in my remix app that depends on node:crypto into a different package in my monorepo. However, now the remix build throws the following error. I'm The package "node:crypto" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

I tried setting serverPlatform to node in remix.config.js, but that seems to have no effect. How do I do what this error message is suggesting?

mild radish
#

Also, in case anyone is wondering, this code was "re-exported" to ensure that it ended up in the server bundle. so I have a file: models/accounts.server that exports everything from the other package in my monorepo. In addition, this code is only referenced from within loaders.

rigid crescent
mild radish
#

express

#

My guess is that somehow remix thinks my code is supposed to go into the client bundle, but I'm not sure why. The error doesn't provide any context as to whether its buildng the client or the server; I assume since its not bundling for node, this happening when it tries to build the client.

rigid crescent
#

that's interesting, I'm not sure how remix handles client vs server build files. Have you tried moving anything that file touches into a .server file?

mild radish
#

I did. I started going through the remix source to understand what was happening, but realized it would be faster to just refactor. I moved the code that remix was complaining about move into server.js, and "dependency injected it" to the class that needed it.

mild radish
#

^^ Although I didn't fix it, I can say for sure that it was because the code that leveraged node:crypto was being bundled in the client. My guess is a module side effect I couldn't track down.