How do you resolve workspace dependencies?

I have a package @me/xyz in the same monorepo as my worker. I list the package as in the worker's package.json dependencies entry as workspace:^. It runs in wrangler dev fine. When I try to deploy, however, I get this error:
Could not resolve "@me/xyz" You can mark the path "@me/xyz" as external to exclude it from the bundle, which will remove this error.
How do I fix this?
4 Replies
_Pear
_Pear•9mo ago
Hi. Do you have a build step for that dependency? If you're using pnpm you can use pnpm deploy, which will output your project in a new dir with all the dependencies it needs. Then you can deploy from that (Just confirmed this myself with some workspace packages). If you're using plain npm or yarn, I'm not sure off the top of my head.
quisi.do
quisi.doOP•9mo ago
Sorry, let me understand. If you deploy from local, it works? It may be that I just left out the build artifact from my pipeline when I deploy. I hope it's that simple. 😊
_Pear
_Pear•9mo ago
yes could be as simple as building! I don't deploy locally. The pnpm command that bundles your app for deployment is called deploy but it would be a separate step from wrangler pages deploy
_Pear
_Pear•9mo ago
again this is if you're using pnpm for your workspace: https://pnpm.io/cli/deploy idk if it's even necessary tbh! but using it, i know all of my code and dependencies are bundled and ready to go.
pnpm deploy | pnpm
Deploy a package from a workspace. During deployment, the files of the deployed package are copied to the target directory. All dependencies of the deployed package, including dependencies from the workspace, are installed inside an isolated node_modules directory at the target directory. The target directory will contain a portable package that...
Want results from more Discord servers?
Add your server