Next.js Discord

Discord Forum

next dev --turbo failed with module not found

Unanswered
Turkish Van posted this in #help-forum
Open in Discord
Turkish VanOP
## Error
the error shows in image in the appendix. And It will work correctly if I clear turbo flag. But I still want to use turbo.

## I tried to fix

my project is a monorepo project by turborepo and pnpm, the directory tree is followed,
├──apps
│  ├──community     
│  └──xxxxx         
└──packages
   ├──typescript-config   
   ├──ui               
   └──utils              

The error happend in my community pacakge, when I import a module with suffix .ts( import tsx will not get errors). I have found the problem was casusd by the exports in pacakge.json in directory of UI,
    "exports": {
        "./globals.css": "./src/globals.css",
        "./lib/*": "./lib/*.ts",
        "./components/*": [
            "./components/*.tsx",
            "./components/*.ts"
        ],
    },

If i changed the exports to
    "exports": {
        "./globals.css": "./src/globals.css",
        "./lib/*": "./lib/*.ts",
        "./components/*": "./components/*",
        "./components/*/*.ts": "./components/*/*.ts",
        "./components/*/*.tsx": "./components/*/*.tsx",
    },

next dev --turbo will work correctly, but my vscode editor (tsc plugin) will give me errors that it cannot found module import from UI pacakge. So can anyone show me how to solve the problem

Thanks a lot

0 Replies