question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doesn’t resolve module with `moduleResolution: "classic"`

See original GitHub issue

Hi, with a file containing

import C from './components/C'

i get:

🚨   rpt2: /home/phil/Dev/Web/flying-sheep.github.com/src/index.tsx (4,15):
Cannot find module './components/C'.

even though it’s there:

$ tree src
src
├── components
│   └── C
│       ├── index.tsx
│       ├── style.css
│       └── style.css.d.ts
└── index.tsx

if i change it to this:

import C from './components/C/index'

i get:

🚨   Could not resolve './components/C/index' from
/home/phil/Dev/Web/flying-sheep.github.com/src/index.tsx

my tsconfig.json has:

"include": [
	"src/**/*"
]

and my rollup.config.js:

plugins: [
	nodeResolve(),
	commonjs(),
	typescript({
		verbosity: 3,
		clean: true,
		check: true,
	}),
]

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
flying-sheepcommented, Mar 31, 2017

ah! so classic doesn’t consider index.{js,ts}{x,}. thanks!

1reaction
ezolenkocommented, Mar 31, 2017

Setting module resolution to “node” works:

======== Resolving module './components/C' from 'C:/sandbox/rollup-typescript-test/src/index.tsx'. ========
Explicitly specified module resolution kind: 'NodeJs'.
Loading module as file / folder, candidate module location 'C:/sandbox/rollup-typescript-test/src/components/C'.
File 'C:/sandbox/rollup-typescript-test/src/components/C.ts' does not exist.
File 'C:/sandbox/rollup-typescript-test/src/components/C.tsx' does not exist.
File 'C:/sandbox/rollup-typescript-test/src/components/C.d.ts' does not exist.
File 'C:/sandbox/rollup-typescript-test/src/components/C/package.json' does not exist.
File 'C:/sandbox/rollup-typescript-test/src/components/C/index.ts' does not exist.
File 'C:/sandbox/rollup-typescript-test/src/components/C/index.tsx' exist - use it as a name resolution result.
======== Module name './components/C' was successfully resolved to 'C:/sandbox/rollup-typescript-test/src/components/C/index.tsx'. ========

tsconfig.json

{
	"compilerOptions": {
		"module": "es2015",
		"jsx": "react",
		"moduleResolution": "node"
	},
	"include": [
		"src/**/*"
	]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript with classic moduleResolution work incorrect
As statet in the TypeScript Documentation: Module Resolution Strategy Classic: This used to be TypeScript's default resolution strategy.
Read more >
Documentation - Module Resolution - TypeScript
If you are having resolution problems with import s and export s in TypeScript, try setting moduleResolution: "node" to see if it fixes...
Read more >
Typescript does not resolve modules through tsconfig.json's ...
Unfortunately still seeing this issue. I have `moduleResolution: node` set as well. It seems that Webstorm is struggling to re-index and find ......
Read more >
Configuring Module Resolution On Typescript and Jest
Step 1: Setting up a basic service. · Step 2: Configuring path resolution on tsconfig.js · Step 3: Configuring the NodeJS runtime to...
Read more >
Module Resolution Strategy | TypeScript Tutorial - YouTube
Access 7000+ courses for 60 days FREE: https://pluralsight.pxf.io/c/1291657/424552/7490 "How does TypeScript compiler find a module ?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found