Skip to content
This repository has been archived by the owner on Dec 1, 2019. It is now read-only.

Cannot read property 'exclude' of undefined #190

Closed
SteveVanOpstal opened this issue Jul 12, 2016 · 59 comments
Closed

Cannot read property 'exclude' of undefined #190

SteveVanOpstal opened this issue Jul 12, 2016 · 59 comments

Comments

@SteveVanOpstal
Copy link

The full error:

Module build failed: TypeError: Cannot read property 'exclude' of undefined at applyDefaults (...\node_modules\awesome-typescript-loader\src\instance.ts:267:72)

The line of code where the error occurs (here) seems like the first point where compilerConfig is used.
So it seems like atl is unable to find or read my tsconfig.json file, it is however at the root and contains nothing out of the ordinary:

{
  "allowJs": true,
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "dist"
  ],
  "filesGlob": [
    "./src/**/*.ts",
    "./test/**/*.ts",
    "!./node_modules/**/*.ts",
    "src/custom-typings.d.ts",
    "typings/index.d.ts"
  ],
  "awesomeTypescriptLoaderOptions": {
    "useCache": true,
    "forkChecker": true,
    "cacheDirectory": "node_modules/.awesome-typescript-loader-cache"
  },
  "compileOnSave": false,
  "buildOnSave": false
}
@SteveVanOpstal
Copy link
Author

The compilerConfig object content:

{ options: 
   { target: 2,
     module: 5,
     moduleResolution: 2,
     sourceMap: true,
     emitDecoratorMetadata: true,
     experimentalDecorators: true,
     removeComments: false,
     noImplicitAny: false },
  fileNames:  [ 'files' ],
  errors: [] }

It lacks the expected typingOptions:

typingOptions: { enableAutoDiscovery: false, include: [], exclude: [] },

Haven't found the cause for this issue yet.

@aspirisen
Copy link

Had the same issue, upgrading to TypeScript 1.8.10 helped

@Marianogboo
Copy link

please i am having this same issue and typescript is 2.0.2. please i need a fix as soon as possible.

@CuriousCain
Copy link

Yeah, I'm having this issue also on 2.0.2 and the very latest dev-version.

@Heliosare
Copy link

Same issue with tsc => Version 2.0.10

@Marianogboo
Copy link

Marianogboo commented Nov 24, 2016

Guys you need to do an npm cache clean, npm install and npm install -g angular-cli while you run as admin

Worked for me

@Heliosare
Copy link

Heliosare commented Nov 24, 2016

Thanks! Its working

@kvey
Copy link

kvey commented Nov 29, 2016

compilerConfig.typingOptions.exclude = compilerConfig.typingOptions.exclude || [];
in latest release version 2.2.4 uses typingOptions, latest typescript nightly uses typeAcquisition instead I believe? Master version of awesome-typescript-loader doesn't have the line, so probably resolved in next release

@DenysVuika
Copy link

Having the same problem with latest Typescript

@joxford-soltech
Copy link

Yep, this is breaking with Typescript 2.1.4.

@sumitarora
Copy link

using version 2.0.10 solves the issue any version starting 2.1.x have the issue

@lisamartin00
Copy link

Based on what kvey is saying, a temporary solution is to open node_modules/awesome-typescript-loader/dist/instance.js and comment out the offending line.

@paynoattn
Copy link

Installing [email protected] as suggested by @sumitarora fixed it for me. So is this an awesome-typescript-loader bug, a tsconfig change that needs to take place, or a typescript bug?

@kvey
Copy link

kvey commented Dec 7, 2016

It should be an awesome-typescript-loader bug (or just incompatibility with > typescript 2.0, where the key typingOptions was changed) but the resolution for it is already available in whatever release is next (because the issue isn't in the current master).

timmyg added a commit to crdschurch/crds-signin-checkin that referenced this issue Dec 7, 2016
@squadwuschel
Copy link

Everythink is working with TypeScript Version 2.0.10 but when you upgrade your TypeScript Version to 2.1.4 the above error shows up. There are some changes that are not working with the Loader

@amcdnl
Copy link

amcdnl commented Dec 7, 2016

Yup, getting same here just now. :(

@sfmskywalker
Copy link

Here too. :(

@ethanve
Copy link

ethanve commented Dec 7, 2016

Here too

@wfe8006
Copy link

wfe8006 commented Dec 8, 2016

Same here, downgrading to typescript 2.0.10 fixed the issue

@BharathLenin
Copy link

Got this error today as well

@KacerCZ
Copy link

KacerCZ commented Dec 8, 2016

Using Typescript 2.1.1 also "fixes" this issue.

@mduta
Copy link

mduta commented Dec 8, 2016

still having issues with both 2.0 and 2.1.1

@VorgaT1339
Copy link

VorgaT1339 commented Dec 8, 2016

This error appeared after upgrading to TypeScript 2.1.4 (from 2.0.10) and downgrading back to 2.0.10 does not fix issue. Switched to ts-loader until things are settled.

@squadwuschel
Copy link

@VorgaT1339 Have you cleared our node_modules folder and reinstalled all your dependencies? Then it should work again.

@readme42
Copy link

readme42 commented Dec 8, 2016

This morning our builds are failing because

"typescript": "^2.0.10"

installs 2.1.4 now.

Nailing it down to "typescript": "2.0.10" solves this for the moment, but the Issue should remain open.

@readme42
Copy link

readme42 commented Dec 8, 2016

#293

@kekeh
Copy link

kekeh commented Dec 8, 2016

Changing

"typescript": "^2.1.1", 

to

"typescript": "2.1.1",

worked.

@sanyamkamat
Copy link

Mine worked by changing

"typescript": "^2.0.3",

to

"typescript": "2.0.10",

made it load the typescript module which doesn't break the awesome-typescript-loader module

@roshan3133
Copy link

Its fixed with "typescript": "^2.1.4" and "awesome-typescript-loader": "^3.0.0-beta.9"
and working fine

@sdudziak
Copy link

sdudziak commented Dec 25, 2016

Edit: [Wrong solution]

This code is resolving the issue; I don't want to create MR, so please apply, test it and close it soon.
function applyDefaults(configFilePath, compilerConfig, loaderConfig) { compilerConfig.raw.compilerOptions.exclude = compilerConfig.raw.compilerOptions.exclude || [];

@DanielFallon
Copy link
Contributor

@sdudziak

that code appears to have a couple of issues.

If that's the exclude from tsconfig.json, that is semantically different from a not specified exclude. (exclude in the default typescript implementation excludes node_modules, bower_componenets etc by default.)
see: commandLineParser.ts, line 849-868

irrespective of that. the compilerOptions node should be of type ts.CompilerOptions, which doesn't contain an exclude. if we are asking for exclude of compilerConfig.raw.compilerOptions, then that is just systemic of another bug.

Based on my previous reading of the code, @s-panferov seems to have a couple of places where he convolutes CompilerOptions and LoaderConfig. Its actually a problem in the loader plugin because it makes it so you can't specify many of the loader options because they conflict with compilerConfig.

All in all, if the above line fixes it, it doesn't seem like the right fix.

@sdudziak
Copy link

@theelf

I haven't analysed this code so deeply, so you are probably right. My intention was to make quick-fix only.

DanielFallon added a commit to DanielFallon/awesome-typescript-loader that referenced this issue Dec 26, 2016
Creating a fix based on s-panferov#190

I have not tested this fix, I'm contributing it for evaluation
@DanielFallon
Copy link
Contributor

fair enough @sdudziak

If you're up for it, this looks like it needs a pretty substantial go through/rewrite for webpack2

I'm still deciding if I'm going to work on that, or just see about improving performance in ts-loader. at-loader has been way useful, but its not in good shape with the new APIs from both webpack 2 and typescript 2.

Thanks for tossing in your quick fix, I submitted a PR with a hack comment that refs this issue to help us remember to remove it later

@KristiyanVachev
Copy link

Yup, downgrading to 2.0.10 worked.
Just type npm install [email protected]

@RyanBalfanz
Copy link

@KristiyanVachev Same, that also worked for me. Thanks!

@luke88jones
Copy link

I've had this same issue but found I could use Typescript 2.1.4 with the latest, beta, version of atl, The only issue I had then was that it seems that the webpack entry points are now case sensitive (on windows at least).

@ghost
Copy link

ghost commented Jan 4, 2017

Installing [email protected] and awesome-typescript-loader@¨2.2.4 as suggested by @sumitarora fixed it for me too.
Is it going to be fixed in v3 ( with typescript 2.1.X ). ???
Happy New Year to all of you...

@szahn
Copy link

szahn commented Jan 5, 2017

+1 This failed for me

{
    "awesome-typescript-loader": "^2.2.4",
    "typescript": "^2.0.10",
}

This worked: guess it had to be the exact version

{
    "awesome-typescript-loader": "=2.2.4",
    "typescript": "=2.0.10",
}

DanielSchuech added a commit to DanielSchuech/ng2-contextmenu that referenced this issue Jan 11, 2017
version 2.2.4 doesnt work with latest typescript version
s-panferov/awesome-typescript-loader#190
upgrade to latest version which seems to be an beta version
ds82 pushed a commit to ds82/ng2-contextmenu that referenced this issue Jan 11, 2017
version 2.2.4 doesnt work with latest typescript version
s-panferov/awesome-typescript-loader#190
upgrade to latest version which seems to be an beta version
srnux pushed a commit to srnux/retain-app that referenced this issue Jan 14, 2017
@jonbiere
Copy link

modifying my typescript package.json reference to a specific version fixed it for me. Thanks for the help. Wil likely upgrade to recent version of typescript once this issue is fixed with awesome-typescript loader.

"typescript": "=2.0.10"

@gjoris
Copy link

gjoris commented Feb 21, 2017

At the time of writing, this problem still persists. The fix above still works, though.

{
    "awesome-typescript-loader": "=2.2.4",
    "typescript": "=2.0.10",
}

@szahn
Copy link

szahn commented Mar 6, 2017

Still no support for Typescript 2.2.1? Guess it's time to switch back to ts-loader.

@raybooysen
Copy link
Contributor

@szahn what a silly thing to say. If it's that much of an issue, feel free to submit a PR.

@s-panferov
Copy link
Owner

[email protected] supports latest TypeScript from the moment of its foundation.

Repository owner locked and limited conversation to collaborators Mar 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests