Next.js Discord

Discord Forum

(Turborepo & NPM Workspaces) Having trouble with resolving tsc related build problems

Answered
gin posted this in #help-forum
Open in Discord
Avatar
ginOP
So, for the last 1 day i have been trying to resolve this annoying issue which is really getting on my nerves. I cant seem to figure out how why this really happens and i tried everything i know.

Basically im trying to simply import this file in my api like this ->
import {subscribeQueue} from "@org/providers/rabbit";

subscribeQueue("test", async (msg) => {
    console.log(msg);
});


In picture 4 is the error, also here the same in the terminal but without a potential fix from the ide ->
org-frontend-api:dev: TSError: ⨯ Unable to compile TypeScript:
org-frontend-api:dev: index.ts(10,30): error TS2307: Cannot find module '@org/providers/rabbit' or its corresponding type declarations.
Image
Image
Image
Image
Answered by gin
Ok... I tried literally everything one by one and this ts config in my api project resolved the issue ->
"module": "commonjs",
"moduleResolution": "bundler",
View full answer

9 Replies

Avatar
ginOP
i tried setting the moduleResolution to node16 but this introduces new errors and i think it makes things worse
i also have the types package which has the exactly same package.json and tsconfig and i can correctly import those in my both projects
in web and api
tsconfig from providers in the screenshot. The only difference is the esModuleInterop option set to true cause rabbitmq uses some weird commonjs only modules
Image
https://www.typescriptlang.org/tsconfig/#moduleResolution is telling me to use node16 but that gives new errors, if you like to know which ones i can provide them here
if someone had dealt with this previously and can provide some help i would appreciate it
Avatar
ginOP
im thinking of just sacking this package and just have it defined independently in my nextjs and api project
but that would ruin the usability cause if i change something to it i would have to change it everywhere :/
Avatar
ginOP
Ok... I tried literally everything one by one and this ts config in my api project resolved the issue ->
"module": "commonjs",
"moduleResolution": "bundler",
Answer