Next.js Discord

Discord Forum

None of my Next.js "next" imports can be resolved.

Answered
Nile Crocodile posted this in #help-forum
Open in Discord
Nile CrocodileOP
I changed my TSConfig recently in order to be able to transpile my package.json scripts with ts-node/esm. The only things I did was change/add these. Now it can no longer resolve my next imports (next/image, etc.) Any idea what's wrong / what to do?

"module": "NodeNext",
"moduleResolution": "nodenext",
"allowImportingTsExtensions": true,


My baseUrl is also "./src"
Answered by Nile Crocodile
In the end, I went back to node moduleResolution anyway. 😆 Just needed --experimental-specifier-resolution=node flag on ts-node/esm
View full answer

6 Replies

Nile CrocodileOP
The baseUrl is the issue, sort of. I've been using it all along as that, but I guess with the other configuration options, it causes issue. I just adjusted my alias path-matching. This has allowed me to run dev again, and it seems the next imports are working, but it's still showing them as red underlined and I can't cmd+click to source.
Nile CrocodileOP
Bump.
Asian black bear
Bumps are only allowed once every 24h, please be patient.
Nile CrocodileOP
Realized that adding .ts to the next imports seems to resolve it. Not ideal, but it is what it is I guess.
Nile CrocodileOP
Ah, even better, adding "next/*": [ "./node_modules/next/*.ts" ] to paths in tsconfig seems to resolve it completely.
Nile CrocodileOP
In the end, I went back to node moduleResolution anyway. 😆 Just needed --experimental-specifier-resolution=node flag on ts-node/esm
Answer