Skip to content

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

Open
@stephenjason89

Description

@stephenjason89

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions