"Unable to resolve path to module" in monorepo, after Angular 13 upgrade

See original GitHub issue

After upgrading to Angular 13, which only supports Angular Package Format and ESModules, we are seeing “Unable to resolve path to module” issues.

Our code is a monorepo using Yarn Workspaces, with TSConfig path aliases set up to point to the built assets of our library packages, so @foo/bar is set up to resolve to the directory node_modules/@foo/bar/dist, which contains a package.json file, a type definition file called foo-bar.d.ts and folders for built assets. The package.json file in the built assets contains a typings entry, that references foo-bar.d.ts.

The issue is that getMappedPath only looks for files, not directories. If this line is removed, or a check is added for a directory as well as a file, then the mapped path is the folder containing the library, and enhanced-resolve correctly resolves the module and its types as it parses the typings key inside package.json.

See https://github.com/import-js/eslint-import-resolver-typescript/pull/187 for a suggested fix

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
JounQincommented, Sep 28, 2022

Thanks for issue first, can you provide a minimal reproduction with ng-cli maybe first? I’m also using Angular 13+, but didn’t meet this problem. So I need to confirm and understand the root cause first.

0reactions
JounQincommented, Oct 20, 2022

close via #187

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using eslint with typescript - Unable to resolve path ...
As soon as I compile the .ts file to a .js, the error goes away. However, since eslint is supposed to work with...
Read more >
ESLint: Unable to resolve path to module #1180
We have solution for absolute path, like this: import MyComponent from 'src/components/MyComponent' It is work fine for yarn start, ...
Read more >
nrwl-nx/community - Gitter
I moved the contents of the folder into libs/components/src/lib, but none of the files are found because it seems like the lib only...
Read more >
eslint-plugin-import
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import ...
Read more >
Workspace and project file structure
A newly generated application contains source files for a root module, with a root component and template. When the workspace file structure is...
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