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.

@floating-ui/dom is broken with typescript 4.7 `node16` module resolution

See original GitHub issue

When enabling "moduleResolution": "node16" in tsconfig.json, tsc now uses the exports field of package.json to look up imports.

So when i do:

import { arrow, autoUpdate, computePosition, flip, offset, shift, size } from '@floating-ui/dom';

If successfully finds it:

======== Module name '@floating-ui/dom' was successfully resolved to '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/dom/index.d.ts' with Package ID '@floating-ui/dom/index.d.ts@0.5.1'. ========

But then it fails when @floating-ui/dom wants to import @floating-ui/core/src/detectOverflow (see https://github.com/floating-ui/floating-ui/blob/master/packages/dom/src/types.ts#L14):

======== Resolving module '@floating-ui/core/src/detectOverflow' from '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/dom/src/types.d.ts'. ========
Explicitly specified module resolution kind: 'Node16'.
'baseUrl' option is set to '/Users/jzwartepoorte/Projects/dna', using this value to resolve non-relative module name '@floating-ui/core/src/detectOverflow'.
Resolving module name '@floating-ui/core/src/detectOverflow' relative to base url '/Users/jzwartepoorte/Projects/dna' - '/Users/jzwartepoorte/Projects/dna/@floating-ui/core/src/detectOverflow'.
Loading module as file / folder, candidate module location '/Users/jzwartepoorte/Projects/dna/@floating-ui/core/src/detectOverflow', target file type 'TypeScript'.
File '/users/jzwartepoorte/projects/dna/node_modules/@floating-ui/dom/src/package.json' does not exist according to earlier cached lookups.
File '/users/jzwartepoorte/projects/dna/node_modules/@floating-ui/dom/package.json' exists according to earlier cached lookups.
Loading module '@floating-ui/core/src/detectOverflow' from 'node_modules' folder, target file type 'TypeScript'.
Directory '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/dom/src/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
Directory '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/dom/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
Directory '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
File '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/core/package.json' exists according to earlier cached lookups.
Export specifier './src/detectOverflow' does not exist in package.json scope at path '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/core'.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
Directory '/Users/jzwartepoorte/Projects/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
Directory '/Users/jzwartepoorte/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'floating-ui__core/src/detectOverflow'
'baseUrl' option is set to '/Users/jzwartepoorte/Projects/dna', using this value to resolve non-relative module name '@floating-ui/core/src/detectOverflow'.
Resolving module name '@floating-ui/core/src/detectOverflow' relative to base url '/Users/jzwartepoorte/Projects/dna' - '/Users/jzwartepoorte/Projects/dna/@floating-ui/core/src/detectOverflow'.
Loading module as file / folder, candidate module location '/Users/jzwartepoorte/Projects/dna/@floating-ui/core/src/detectOverflow', target file type 'JavaScript'.
File '/users/jzwartepoorte/projects/dna/node_modules/@floating-ui/dom/src/package.json' does not exist according to earlier cached lookups.
File '/users/jzwartepoorte/projects/dna/node_modules/@floating-ui/dom/package.json' exists according to earlier cached lookups.
Loading module '@floating-ui/core/src/detectOverflow' from 'node_modules' folder, target file type 'JavaScript'.
Directory '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/dom/src/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/dom/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/node_modules' does not exist, skipping all lookups in it.
File '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/core/package.json' exists according to earlier cached lookups.
Export specifier './src/detectOverflow' does not exist in package.json scope at path '/Users/jzwartepoorte/Projects/dna/node_modules/@floating-ui/core'.
Directory '/Users/jzwartepoorte/Projects/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/jzwartepoorte/node_modules' does not exist, skipping all lookups in it.
Directory '/Users/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@floating-ui/core/src/detectOverflow' was not resolved. ========

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jpzwartecommented, May 27, 2022

No, I’ve searched the codebase for any other @floating-ui/core/src/.... imports, but there were none in any react packages.

0reactions
jpzwartecommented, May 27, 2022

Thanks, I’ll look into patch-package.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript module "Node16" does not resolve types of CJS ...
To expand on this, TypeScript 4.7.1-rc with nodenext module resolution is unable to resolve various NPM dependencies. See this example repo.
Read more >
Add file extension when '--moduleResolution' is 'node16' or ...
TypeScript 4.7 checks package.json's type field and tsconfig's moduleResolution . So we need to insert the extension only if these two options are...
Read more >
Typescript module resolution not working - Stack Overflow
Even though intellisense works fine in VSCode the transpiled javascript files throw an exception: Cannot find module . My project structure:.
Read more >
Common TypeScript module problems and how to solve them
Enabling the compiler module resolution tracing in TypeScript can provide insight in diagnosing and solving problems.
Read more >
TypeScript 4.7 crosses the finish line - InfoWorld
The latest version of Microsoft's strongly typed JavaScript introduces support for ECMAScript modules in Node.js, adds coding enhancements.
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