Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript not ignoring node_modules

Tags:

typescript

My directory structure:

  • frontend

    -- node_modules

  • backend

    -- node_modules

  • tsconfig.json

In my tsconfig.json, I have:

"exclude": [
    "frontend/node_modules", "backend/node_modules"
  ]

Still, I get errors from packages in node_modules.

What am I doing wrong?

// Per

like image 523
Joe Avatar asked Jan 10 '19 08:01

Joe


1 Answers

Why "exclude" doesn't work:

"exclude" only prevents items from being included by "include"; it doesn't prevent them from being included via import statements or <reference>s. If you import [the module] levelup, and levelup imports leveldown, then excluding leveldown or node_modules won't have an effect. (reddit)

TS reference: https://www.typescriptlang.org/tsconfig#exclude

Maybe you should try the option --skipLibCheck.

See also the FAQ: Why is a file in the exclude list still picked up by the compiler?

like image 92
Paleo Avatar answered Nov 08 '22 07:11

Paleo