TypeScript Version: 2.4.0
Code
import * as Vue from "vue";
console.log(Vue);
{
"compilerOptions": {
"target": "es5",
"module": "esnext"
}
}
Expected behavior:
no error.
Actual behavior:
error TS2307: Cannot find module 'vue'.
Reference 1 of js file with same source code:
Result: works fine with webpack.
Reference 2 of with same source code and this tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs"
}
}
Result: no compilation error, and works fine with webpack.
Try setting moduleResolution to node.
Solved.
Maybe better document about this at here: https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Compiler%20Options.md
Most helpful comment
Try setting
moduleResolutiontonode.