Avoid turbo circular dependency error while using npm run dev in non-monorepo (polyrepo) setup
#8200
Replies: 2 comments
-
|
I'm facing a similar issue when using the root package as a published NPM package so my NPM workspaces has a workspace pointing to the root For now I removed the NPM scripts from the root package and documented to use the |
Beta Was this translation helpful? Give feedback.
-
|
I also just realized turbo engine, turborepo, and turbopack are for different implementations and I should probably just use turbopack via |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This might be an anti-pattern, but I wanted to add Turbo to my NextJS application in a non-monorepo setup and have it run from
npm run devso I don't have to retrain the other contributors (and our CI).At first Turbo was complaining that I'd created a recursive loop:
× root task //#dev (turbo dev) looks like it invokes turbo and might cause a loopTo avoid this I added a conditional to my
package.jsondevscript to check if Turbo was executing it (by checking for the existince of theTURBO_HASHenvironment variable) to runnext devif it was, and moved theturbo devcall to adev:turboscript since it appearsturbo devis parsing thedevscript text for the wordsturbo devto throw the above error.directory structure
package.json:{ ... "scripts": { - "dev": "next dev", + "dev": "if test \"$TURBO_HASH\"; then next dev; else npm run dev:turbo; fi", + "dev:turbo": "turbo dev", ... } ... }Now running
npm run devruns turbo! 🥳This pattern can be applied to
build,start,lint, etc.Hope this helps someone else!
Beta Was this translation helpful? Give feedback.
All reactions