-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
What works in require
results in module not found when using import
#18431
Comments
Same build error with:
But following is fine:
|
For importing .json files in node, please see #7071. See https://www.typescriptlang.org/docs/handbook/module-resolution.html for more information about how the compiler resolves modules. |
Does it mean that, for the two examples listed, the modules are actually resolvable by the run time, but it is just the compiler blocking the build? |
It means that the compiler does not have sufficient information to know they are resolvable at runtime. TypeScript cannot predict the future, it can only interpret the information you provide it. |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
TypeScript Version: 2.3
Visual Studio 2017 15.3.3 Basic Node.js Express Application project
I have the module
emailjs
(https://github.com/eleith/emailjs) installed globally. It is located in C:\Users\xxx\AppData\Roaming\npm\node_modules. This path is set in the project properties.If I use
var email = require("emailjs/email")
, it works fine.But if I use
import * as email from "emailjs/email"
, it will fail with:The text was updated successfully, but these errors were encountered: