TypeScript Version: 3.1.1
Search Terms:
TS2307 Cannot find module
Code
See repo https://github.com/matthewadams/TS2307
Expected behavior:
No error error TS2307: Cannot find module 'aspect.js' during transpilation when using npm module aspect.js
TS2307-cannot-find-module.zip
TS2307-cannot-find-module.zip
TS2307-cannot-find-module.zip
Actual behavior:
Clone https://github.com/matthewadams/TS2307, then:
$ npm i
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
added 292 packages from 730 contributors and audited 678 packages in 5.901s
found 0 vulnerabilities
$ ./node_modules/.bin/tsc
src/main/Thing.ts:1:33 - error TS2307: Cannot find module 'aspect.js'.
1 import { Wove as Advised } from 'aspect.js'
~~~~~~~~~~~
src/main/aspects/Aspect.ts:11:8 - error TS2307: Cannot find module 'aspect.js'.
11 } from 'aspect.js'
~~~~~~~~~~~
TSFILE: /private/tmp/TS2307/lib/json.js
TSFILE: /private/tmp/TS2307/lib/json.d.ts
TSFILE: /private/tmp/TS2307/lib/aspects/Aspect.js
TSFILE: /private/tmp/TS2307/lib/aspects/Aspect.d.ts
TSFILE: /private/tmp/TS2307/lib/Thing.js
TSFILE: /private/tmp/TS2307/lib/Thing.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.es6.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.es5.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.es2015.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.dom.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.dom.iterable.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.webworker.importscripts.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.scripthost.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.es2015.core.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.es2015.collection.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.es2015.generator.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.es2015.iterable.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.es2015.promise.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.es2015.proxy.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.es2015.reflect.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.es2015.symbol.d.ts
/private/tmp/TS2307/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts
/private/tmp/TS2307/src/main/json.ts
/private/tmp/TS2307/src/main/aspects/Aspect.ts
/private/tmp/TS2307/src/main/Thing.ts
/private/tmp/TS2307/node_modules/@types/chai/index.d.ts
/private/tmp/TS2307/node_modules/@types/mocha/index.d.ts
/private/tmp/TS2307/node_modules/@types/node/inspector.d.ts
/private/tmp/TS2307/node_modules/@types/node/index.d.ts
Playground Link:
Included project that includes reproducible bug.
Related Issues:
None
Looks like this may be a duplicate of https://github.com/Microsoft/TypeScript/issues/16444 -- didn't see that issue when creating
Definitely a duplicate of https://github.com/Microsoft/TypeScript/issues/16444
Not a duplicate of #16444. The problem is that you need "moduleResolution": "node" in your tsconfig.json compiler options, or else TypeScript will never look in node_modules to resolve dependencies.
@andy-ms I have that set and I still have the problem
Most helpful comment
Not a duplicate of #16444. The problem is that you need
"moduleResolution": "node"in yourtsconfig.jsoncompiler options, or else TypeScript will never look innode_modulesto resolve dependencies.