The “This syntax requires an imported helper but module ‘tslib’ cannot be found” error relates to tslib library. What is the cause of it and how to fix it? Let’s go into detail.
Reason for the “This syntax requires an imported helper, but module ‘tslib’ cannot be found” error
The ‘tslib’ library helps you to avoid code duplication of helper functions as __extends
. Using it, you can save a lot of data, run less time, and optimize your code eventually. There are a lot of reasons for this error, but the most common is you are using the wrong Typescript version. If you get the error like this:
src/index.ts:5:1 - error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found.
You can follow this solution below to fix this error.
How to fix this error?
Solution 1: Install ‘tslib’
First at all, make sure that you have already install ‘tslib’. If not, you can install ‘tslib’ by this command below:
npm I –D tslib@latest
This command will install the latest ‘tslib’ version into dev dependencies.
Solution 2: Set tsconfig.json
You will have to set it in your tsconfig.app.json file if you use Angular or whatever config file you use on your project building.
You can add two lines below:
“importHelpers”: true
: If you are trying to use the helper function.“target”: ”es6”
: This will continue setting which JavaScript feature should be intact.
Example:
{ "compilerOptions": { "importHelpers": true, "target": "es6", "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "jsx": "react-jsx" }, "include": [ "src" ], "exclude": [] }
Solution 3: Delete the “package-lock.json” and “node_modules” file
You can remove the “package-lock.json” and “node_modules” files by command:
rm –rf node_modules package-lock.json
Then you can reinstall by command:
npm install
Then remember to restart your IDE to apply your change.
include
and files
options in tsconfig.json will set the file that you are working with and inside your project. If you are using them, make sure you include your file.
exclude
option will skip the file you are not working with, so make sure you are not excluding your file.
Summary
In this tutorial, I’ve explained how to solve the “This syntax requires an imported helper, but module ‘tslib’ cannot be found” error. You can install ‘tslib’ library with the command npm install –D tslib@latest
or set importHelper
or target
properties in the tsconfig.json file.
Maybe you are interested:
- Type ‘null’ is not assignable to type in TypeScript
- Cannot find name ‘require’ error in typescript
- Cannot redeclare block-scoped variable in TypeScript

Hello, guys! I hope that my knowledge in HTML, CSS, JavaScript, TypeScript, NodeJS, ReactJS, MongoDB, Python, MySQL, and npm computer languages may be of use to you. I’m Brent Johnson, a software developer.
Name of the university: HOU
Major: IT
Programming Languages: HTML, CSS, JavaScript, TypeScript, NodeJS, ReactJS, MongoDB, PyThon, MySQL, npm