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

Cannot resolve directory '~' with dynamic import('~/dir') #520

Open
stephenjason89 opened this issue Aug 25, 2021 · 0 comments
Open

Cannot resolve directory '~' with dynamic import('~/dir') #520

stephenjason89 opened this issue Aug 25, 2021 · 0 comments

Comments

@stephenjason89
Copy link

stephenjason89 commented Aug 25, 2021

Dynamically imported directory throws this error
image

Normal imports are working fine
image

here is my tsconfig.json

{
    "compilerOptions": {
        "target": "ES2018",
        "module": "ESNext",
        "moduleResolution": "node",
        "lib": ["ESNext", "ESNext.AsyncIterable", "DOM"],
        "esModuleInterop": true,
        "allowJs": true,
        "sourceMap": true,
        "strict": true,
        "noEmit": true,
        "experimentalDecorators": true,
        "baseUrl": ".",
        "paths": {
            "~/*": ["./client/*"],
            "@/*": ["./client/*"]
        },
        "types": ["@nuxt/types", "@types/node"]
    },
    "exclude": ["node_modules", ".nuxt"]
}

Please let me know if you would need more information.

    "@nuxt/typescript-build": "^2.1.0",
    "nuxt": "^2.15.6",

Thank you

A temporary solution would be to write it like 'url' instead of `url`

import('~/graphql/User.js')

I am using template literal because i am dynamically importing based on a variable
import(`~/graphql/${this.model}.js`)

I would need to write this as
import('~/graphql/'+this.model+'.js')
Just to remove the error

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

1 participant