-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using invalid environment causes error in build (was "ERROR in Cannot read property 'length' of undefined") #5053
Comments
@istiti can you fill out the issue template and give the steps to reproduce? What version of the cli are you updating from? |
@deebloo please apologize see point 1 again.
|
@istiti Did you use If so, make sure that you kept all original arrays in |
@metamaker no I don't use ng new I have assets styles and scripts as array. |
Provide your |
https://gist.github.com/istiti/e544744f16480829416e62b32167051e ps: when running ng new test --ng4 it works... but I want get working again my existing project |
Your |
additional info : then move all my old /app folder to this new one and I get same error ! apparently the issue is in my code/module ... My project is relativly big I can't remove module by module :( how achieve this ? can I get more signifiant message error thanks |
This is a real issue and we will look at it. |
Additionals infos: Thanks, actually can't move... Cc @hansl |
@isiti can you provide a repository or some sort of code sample that we could use to reproduce? Maybe your package.json might be enough, if you're okay to share that. |
Will do it tomorrow at 7AM (UTC +1) Thanks coz can't move (actually blocked) |
I was experiencing the same issue here and after I rolled typescript back from |
@hansl here you are https://gist.github.com/istiti/f97eb83c6d18fd1d23965e4a3325033e @trentmswanson FYI after passing from 2.1.6 to 2.0.10 I get this error then when I update typescript from 2.0.10 to 2.2.1 I get same error as in 2.1.6 |
The strange thing here: the project with angular-cli rc.0 was working fine till executing the first When I setup a new project, it is possible to build. I removed and reinstalled angular-cli like documented (including node_modules) - the same. Also downgraded Typescript to 2.0.0 like the default for a blank project and took all possible settings of a blank project. |
Checking out from the repository into a new directory and running |
As said : I putt in new green cli --ng4 project whole my /app folder and same issue |
Apart from the lack of a descriptive message (which is the main focus for this issue), should anyone run into this case, don't panic - chances are that it's just a temporary glitch. I ran into this situation twice and it looked like a local problem with syncing files. The second incident of mine was a bit more clear to me - it followed a FWIW: Since this is |
additional info: same behavior with angular rc2 |
additional infowith this conf. my project works/compile fine with typescript 2.1.6 here's my working package.json:
BUT it breakswhen I add these lines to my package.json, I get
|
same issue for me. I get this error only when building/serving with --prod flag:
|
I have the same issue on ubuntu 14.04 with node 7.6.0, npm 4.1.2 when running:
|
Probably not the same cause but we had the same error ( |
@moosetraveller Thanks a lot. This actually happened to be the issue. On our staging server we had no environment file set up. |
nop, it's not same cause... I have this file under |
Issue was resolved by adding an |
Had the same issue, turned out that in node_modules/typescript/lib/typescript.js (line 12619) the sourceText variable was undefined somehow (function code below) . It pointed to the src/environments/environment.ts file (that existed) while the .angular-cli.json dev environment pointed to environments/environment.dev.ts (that existed too). (ng serve --env=dev was executed) package.json:
|
I ran into this error, finally, I found out it was because a typo (exclamation mark inside the string interpolation). I wrote: 'Server with ID {{ serverId }} is {{ serverStatus! }}' instead of 'Server with ID {{ serverId }} is {{ serverStatus }}!' |
Simply delete a component folder and the var sourceFile = new SourceFileConstructor(265 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); I assume typescript is getting passed a file that doesn't exist anymore and fails to create it? Edit: seems that this problem occurs whenever a non existing file attempts to get compiled by typescript. |
There might be an issue with environment.ts file. dialogflow: { |
I did this change and it worked for me. |
@filipesilva Can confirm what @nikdo said, and we fixed by downgrading cli to 1.6.1. I can get some time early next week to debug a little or see if our package.json yields a repro. Mention me if that would help. |
angular/devkit#667 should fix this in 6.0 by failing early when the specified environment file (it will be called |
Marking this nice to have because there seems to be a fix already. |
I created this patch for version 1.7.3 , you can apply the patch to node_modules/@ngtools/webpack/src/plugin.js and you should be good to go.
|
…string styles/scripts Fix angular/angular-cli#5053 Fix angular/angular-cli#10267
To me removing comments from the environments files worked 👍 🔢 |
I solved this problem (error during refactoring test). All is good for angular v4.3.* and v4.4*
|
I have the exact same problem as @FunnyGhost (angular-cli 1.7.0, angular 2.4.10 typescript 2.2.2). Downgrading the angular-cli to 1.6.1 resolved my problem, but version 1.6.1 required angular-devkit/core in devDependencties |
I too like others found the problem to be with the "plugin.js" file within "node_modules@ngtools\webpack\src\plugin.js". The problem is with the "_findLazyRoutesInAst()" function. This function is called on the second pass when running your unit test (w/ Karma). This function only looks at files that have been modified, and there is a file path in the array "this._compilerHost.getChangedFilePaths()" that ends with "/src", and all of the other paths end with .ts files. To resolve this problem, I check the file path to see if it ends with ".ts", and if so, I push that path into an array. Below is my solution to this problem. I would like to submit this as a bug fix, but I do not know where to do so. ------- plugin.js : ln 211 ------- _findLazyRoutesInAst() { |
I have modified this file and it works fine, but it will never be fixed in any new version?
|
I had a similar message recently when I added some new environments files in the angular-cli.json
The problem was I misstyped the name of one of the files: environment.xamp**.**.ts (I typed twice the dot) I was very hard to figure what was wrong with my project (I knew only it had to be something with the environments files). A nice error sugesting about how i misspelled the files would have been perfect :/ |
This error should be improved.. for instance.. in most of the cases is the environment.xxx.ts missing.. so a message where file could not be found would be nice! |
My team has been struggling with this for months, but @mhamel06's comment resolved the issue for me. It would be nice to have an actual fix that doesn't require modification of a lib file though. |
The variant of the problem described by @FunnyGhost in #5053 (comment) is gone in 6.0.7. |
The above comment about the environment file caught my attention. I was with the same problem and looking at my .angular-cli.json I could fix and reproduce the error when one of those files below were missing:
So, those files must exist otherwise this error will happen. The cli could raise a more meaningful error message. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
(on existing project, on windows10) After updating :
I get this insignifiant message error when running
ng serve
orng build
:What does this mean ?
The text was updated successfully, but these errors were encountered: