Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with aliases #412

Open
kacluk123 opened this issue Oct 20, 2020 · 5 comments
Open

Problem with aliases #412

kacluk123 opened this issue Oct 20, 2020 · 5 comments

Comments

@kacluk123
Copy link

Babel resolver does not work in my next.js project

My .babelrc file

    {
      "presets": ["next/babel"],
      "plugins": [
        [
          "module-resolver",
          {
            "root": ["./"],
            "alias": {
              "@components": "./src/components",
            }
          }
        ],
        ["styled-components", { "ssr": true }]
      ]
    }

My tsconfig

    "paths": {
      "@components/*": ["./src/components/*"],
      "baseUrl": "."
     },

And when im trying to use it like that

    import Login from '@components/login'
    
    export default Login

vscode throws an error

Cannot find module '@components/login' or its corresponding type
declarations.

@patrickyyang
Copy link

I have the same error, Did you fix this?

@chunhoong
Copy link

Assume everything is correct- Perhaps try to restart TypeScript language server in vscode?

@MariusCatanoiu
Copy link

MariusCatanoiu commented Aug 25, 2022

This worked for me:

  • I removed node_modules
  • yarn install
  • pod install
  • run
watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* &&
 rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean --force &&
 npm install && npm start -- --reset-cache

And I use it like this
import { AppStateHandler, FocusListeners, LoadingContainer } from '@components';

@Nantris
Copy link

Nantris commented Sep 23, 2022

This is TS2307. @kacluk123 it's good practice to include the error code, not just the text.

Anybody know how to fix it?

@MariusCatanoiu can you clarify what you mean? You were able to get this working?

@MariusCatanoiu
Copy link

This is TS2307. @kacluk123 it's good practice to include the error code, not just the text.

Anybody know how to fix it?

@MariusCatanoiu can you clarify what you mean? You were able to get this working?

I updated the previous comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants