TypeScript + Webpack resolves dependencies in symlink folder

I ran into a problem that TypeScript + Webpack does not allow correct dependencies if they are in a symbolic linked folder. I have a file structure:

- main
-- index.ts
-- package.json
-- webpack.config.js

- shared-lib
-- services
--- session.ts
-- package.json

In mainthere is a dependency for shared-lib@file:../shared-lib, as a result of npm will create a symbolic link for it in node_modules.

In shared-libI have a dependency for lodash-es, and I also have it in main, but that there should be only one in the project lodash-esthat I want to save in main, as a result, when I try to build a project, I get something like:

ERROR in [at-loader] ../shared-lib/index.ts:1:24 TS2307: Cannot find module 'lodash-es/capitalize'.

Webpack , , node_modules resolve.modules. , TypeScript , . TypeScript , TypeScript, , ? rootDirs, , , .

+4
1

, TypeScript 2 ( , , 2) , . npm , , .

, , . baseUrl ., paths, .

.tsconfig :

"baseUrl": ".",
"paths": {
  "lodash-es": ["node_modules/lodash-es"]
},

lodash-es ./node_modules/lodash-es, .

, TypeScript .

0

Source: https://habr.com/ru/post/1681329/


All Articles