Skip to content
Discussion options

You must be logged in to vote

Hi!

The issue is that Next.js needs the same alias configuration in next.config.js. Here's the fix:

1. Update next.config.js:

const path = require('path');

module.exports = {
webpack: (config) => {
config.resolve.alias['@'] = path.resolve(__dirname, 'src');
return config;
},
};

2. Or simpler - just restart the dev server:

Sometimes the alias works after restarting:

  • Stop the server (Ctrl+C)
  • Run npm run dev again

3. Make sure your folder structure matches:

your-project/
├── src/
│ └── components/
│ └── Button.tsx
├── tsconfig.json
└── next.config.js

Hope this helps! 🚀

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@icyJoseph
Comment options

Answer selected by minx-nie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants