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 typings included in npm package when using "moduleResolution": "classic" #18492

Closed
mjbvz opened this issue Sep 14, 2017 · 4 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Sep 14, 2017

From microsoft/vscode#34346

TypeScript Version: 2.5.2

Code
In a new project

$ npm init -y
$ npm install axios
import axios from 'axios';
{
    "compilerOptions": {
        "strict": true,
        "module": "amd",
        "moduleResolution": "classic"
    }
}

Expected behavior:
axios includes its own typings so these should be used for the import

Actual behavior:
Module axios cannot be resolved.

"moduleResolution": "node" fixes the problem

@mhegazy
Copy link
Contributor

mhegazy commented Sep 14, 2017

that is by design. do not use classic unless you have to. the reason it is there is purely back compat.

@mhegazy mhegazy added the Working as Intended The behavior described is the intended behavior; this is not a bug label Sep 14, 2017
@mjbvz
Copy link
Contributor Author

mjbvz commented Sep 14, 2017

Ok, is there a way to work around this without changing the resolution to node?

@mhegazy
Copy link
Contributor

mhegazy commented Sep 14, 2017

add a path mapping entry for module imports.

@mjbvz
Copy link
Contributor Author

mjbvz commented Sep 14, 2017

Thanks @mhegazy! I'll follow up with the user who opened this bug back on the vscode repo

@mjbvz mjbvz closed this as completed Sep 14, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

2 participants