Closed rbiggs closed 6 years ago
Here's a simple repository on Github that illustrates the project. Download, run npm install
. Then try to run TypeScript type checking on the JavaScript using npm run checkjs
.
Interestingly, VSCode seems to have no problem resolving the path for scoped packages:
Version 1.5.3 is from May 2015. VSCode uses a much newer version than that. Is the version correct?
I updated the project to TypeScript 3.0.3 and the same issue occurs.
You need to set --moduleResolution node
. --moduleResolution
defaults to classic
when your target is es6
and node
when your target is the default es3
. See the Compiler Options handbook page for more information. It's highly recommendable to put your TypeScript options in a tsconfig.json
file so you can easily share them between your IDE and your batch build to avoid inconsistencies like this.
Thanks @mattmccutchen. That seems to be what was the problem. With the --moduleResolution node
flag, the tsc check is running fine. Closing this now.
TypeScript Version: TS6029: Version 1.5.3
Search Terms: import scoped packages
Code
In my
package.json
I haveExpected behavior: I'm using NPM scoped packages: https://docs.npmjs.com/misc/scope. For normal ES6 imports TSC correctly resolves imported packages and parses the results. Scoped Scoped packages look like this:
The scope is basically an NPM namespace to prevent collision of package names.
Actual behavior: TSC fails to find the packages. Here's the error message I'm getting:
Rollup and Babel 7.0.0 have no problem with import of scoped packages.