How to do settings for a project with a custom external library?
The below picture shows a very simple test project set up:

There is a client project "external-lib-client-1" which is configured to use custom library "external-lib-1", both are programmed in TypeScript.
Below the debugger is run and it give an error message "Uncaught ReferenceError: exports is not defined". Debugging works if custom libraries are not used in a project.
In the project Settings TypeScript is set up as is shown in the below picture:

If needed I can upload the project files too. Can you help?
请先登录再写评论。
Your issue has absolutely nothing to do with libraries - and with the IDE.
1. JavaScript libraries are not used when running/debugging your code, they are only used by the IDE for code completion, etc.
2. error is thrown because you are likely compiling your TypeScript code to CommonJS format; and browsers do not support it. To use TypeScript for in-browser applications, you have to use bundlers (like webpack, browserify, etc.) or module loaders (like SystemJS)
If anyone else finds their way here, open your tsconfig.json and change "module": "commonjs" to "module": "webpack"
I have to agree with the OP. This stuff should be in part the responsibility of the IDE. If I've installed webpack into my project, WebStorm should be detecting that I'm trying to use typescript and my tsconfig.json still has "commonjs" and not "webpack". Ideally, it would be making that correction automatically or asking the question: I have installed webpack, what are the chances that I want to use it?
One major question springs to mind, other than the obvious one about why you web monkeys have decided to make this so bloody difficult:
Why does tsconfig.json default to CommonJS ("module": "commonjs") in 2019 if "browsers do not support it"? And how is anyone to know what "commonjs" even means? If I google for "commonjs" I get a Wikipedia page that tells me that the one you're all talking about was declared obsolete back in 2013, so why would anyone assume that the appearance in tsconfig.json refers to something that's been obsolete for 6 years? That also means it's very difficult now to find any information about either making it work at all, or migrating away from it. And most of what I find is just "don't use that, use webpack" without any further advice.
>If I've installed webpack into my project, WebStorm should be detecting that I'm trying to use typescript and my tsconfig.json still has "commonjs" and not "webpack"
what about standard configurations, like Angular CLI or React, that are still using different module values? Actually, I'm not aware of any framework that is using "module": "webpack"; and webpack loaders can work with"module": "commonjs"
BTW, can't see webpack listed in https://www.typescriptlang.org/docs/handbook/compiler-options.html
And anyway, modifying users config automatically is not the thing the IDE should do
>Why does tsconfig.json default to CommonJS ("module": "commonjs") in 2019
You can ask Microsoft developers about it:) this is the default module value that is generated when creating a config with tsc --init