-
Notifications
You must be signed in to change notification settings - Fork 311
RC3 - error "build dev failed: Cannot read property 'indexOf' of undefined #468
Comments
Ok, i've find it : my typings/index.d.ts have some old typings, i remove the lines and everything is ok. |
I reported this on the [0.0.42] issue but this one seems more relevant. I do not have any typings, I'm using the @types includes in package.json. I am seeing this same issue. I do not have any modifications to the build setup. The biggest issue for me here, is that I don't know where to start digging. With the "hidden from the devloper" approach to the build config, things like this take way longer to debug. output from ionic info:
Package JSON:
ionic serve output:
|
I am also seeing the same error Here is my output from a serve --debug:
And then the Ionic Info:
|
@ekrapfl I didn't know about the debug flag. This is the same error I'm seeing, with the typescript-logger trying to call indexOf on an undefined object. |
Ok, So I followed the errors and in each place an undefined object was getting refrenced, I protected against it. In the end, I found that a bunch of typescript type errors were being encountered that were failing to get reported. I updated the following lines in
I updated the following lines in
I updated the following lines in
Now all of this just leads me to getting Typescript output again. What I'm running into now is that I'm getting Typescript errors about duplicate core-js definitions. If I remove the @types/core-js dependency, then I get typescript errors importing items from another module because that module expects core-js types.... |
I just learned about the debug flag today 😄 I have also sprinkled a bit of logging code around the area that is failing, and it looks like this (sorry for the large amount of text here):
|
@Barryrowe, I plugged in your code, and now I am seeing tons of errors with simple things like |
@ekrapfl sounds like you're closer to the end than me. If you go into your tsconfig.json file and update your "exclude" block like:
That might get you through this step at least... |
I tried that, and it didn't really change much for me. I am still getting the promise errors in my source code (not just spec files). |
@ekrapfl I had the same issue. I removed the core-js typings from @typings/ folder to get past it. Dunno if that helps. Currently I am struggling to get ionic app scripts to work while pulling in libraries via a cdn. No luck so far. |
@ekrapfl @wspresto you could try installing the @types/core-js package. I know that the typings folder should be removed now that everything has moved to typescript 2, and the @types/core-js package should provide the Promise types that you all need. However, for me it removes some errors, and creates "duplicate PropertyKey" errors because of an npm installed module. |
I think i will create a separate issue in this forum for external dependencies, because I was able to fix my issue after several days of head banging. This thread helped me to get typescript working. As an aside, this has been a nasty introduction to Angular 2 for me. Ionic App Scripts seems to be a bad direction for ionic apps. |
@wspresto I agree so far. I have never been a fan of hiding things from developers, and ionic-app-scripts hides so much "magic" that any use-case outside of the basic tests in the starter apps seem to fail mysteriously. Dealing with a webpack config directly and having full control over your build scripts would feel much better. |
(Having the same issue as #468 (comment)) I've been generally very impressed with Even if a user didn't run with the |
Thanks @Barryrowe, I made a PR to merge your fixes back upstream. P.S.: it appears 90% of my 'hidden' errors pertained |
@tycho01 cool. This makes sense. I noticed I didn't have any issues after a full clean, and I know I had been trying to run As for anyone running into an issue with core-js like I was, I ended up using a fix from a forum post, that I unfortunately don't have at the moment. but I did the following:
I had to do this because a library we install is including core-js types, so they aren't recognized without the @types, and then with the "libs" configuration in the default ionic tsconfig.json there's a duplication of some common types for dropping down to es5 compilation. |
Hi, Just like to share my experience, I got this 'indexOf' of undefined error on our new project, our project builds ok on Windows (10, 2012) but as soon as we tried to ionic serve or ionic build the project on Mac, I get the error. After hours of frustration, I came across this hint where the person suggest compile typescript manually and see if there are any errors. and then I went in the compiled all TS files in project using WebStorm built in compiler. I was getting loadS of error from typing files in node_modules then found and applied suggestion from this stack flow article i.e. add "types": [] to compilerOptions no more compiler error from the project and therefore no more 'indexOf' of undefined, the project is building ok now. Ionic Info Cordova CLI: You have been opted out of telemetry. To change this, run: cordova telemetry on. Ionic Framework Version: 2.0.0-rc.3 |
I think the key point here is that everyone is getting this error for different reasons, because the indexOf error is only encountered when there is another TypeScript error. That's why there are so many contradicting tips on how to fix it. The fix is in PR #502 which should then reveal whichever underlying error you have. |
I merged the PR (and made a few slight modifications for the code consistency/quality). Please let me know if this fixes the issue or if there is a concrete way to reproduce. I am having a hard time recreating this issue. Please make sure Thanks, |
Hi you can recreating the error if you run and run ionic serve but it is more like a problem with angularfire2 https://forum.ionicframework.com/t/build-dev-failed-cannot-read-property-indexof-of-undefined/71506 Thanks, |
@danielehrhardt, yep, we will publish the new app base when we publish RC4. We've seen some delays there. It should be coming soon. Thanks, |
@danbucholtz , As we haunt with build dev failed: Cannot read property 'indexOf' of undefined error, Can you please tell us, what could be the best possible way to move forward with development, with out waiting for RC4 and Any planned date to release RC4. Packages.json: { tsconfig.json: { |
I met this problem. And I found that it seems like called by because when I add line
in my routing file and then I got the error. the full content of my routing file is:
If I remove the 2nd line, it will be ok.But... And I also tried replace 2nd line with |
@subbunama, Sorry, I have no idea what the issue is without code and I don't have time to read through your code to figure it out. The null pointers should be fixed in Thanks, |
Hello All, I hope it helps Thanks |
I believe this is fixed. We published Thanks, |
Hi,
i have this error :
"build dev failed: Cannot read property 'indexOf' of undefined "
when i use "ionic serve"
but if i run "ionic build browser", everything is ok.
I've removed all my node_modules and do a fresh "npm install".
I've deleted the ".tmp" & "www" dir too, but the error still displaying.
Can it be possible to have some detailled information from the console, because the error message is really "light"
Please can you help me ? Thanks you,
best regards
This is my ionic info :
and my package.json :
The text was updated successfully, but these errors were encountered: