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

1 messages · Page 1 of 1 (latest)

mental goblet
#

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"

balmy egretBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

mental goblet
#

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.

mental goblet
#

Bump.

dense turret
#

Bumps are only allowed once every 24h, please be patient.

mental goblet
#

Realized that adding .ts to the next imports seems to resolve it. Not ideal, but it is what it is I guess.

#

Ah, even better, adding "next/*": [ "./node_modules/next/*.ts" ] to paths in tsconfig seems to resolve it completely.

mental goblet
#

In the end, I went back to node moduleResolution anyway. 😆 Just needed --experimental-specifier-resolution=node flag on ts-node/esm