angular-cli: 1.3.0 causes build to fail with - Cannot read property 'range' of null
Bug Report or Feature Request (mark with an x
)
- [x ] bug report -> please search issues before submitting
Versions.
ng --version: 1.3.0 npm --version: 5.3.0 node --version: 8.1.4
Repro steps.
I have lazy loaded routes and feature modules ng build --aot --prod
The log given by the failure.
ERROR in chunk 7
[id].[chunkhash:20].chunk.js
Cannot read property 'range' of null
TypeError: Cannot read property 'range' of null
at enterNode (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:118:14)
at getPathInAst (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:97:24)
at getPathInAst (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:106:24)
at enterNode (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:121:18)
at getPathInAst (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:110:25)
at enterNode (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:121:18)
at getPathInAst (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:97:24)
at getPathInAst (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:106:24)
at enterNode (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:121:18)
at getPathInAst (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:97:24)
at getPathInAst (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:106:24)
at enterNode (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:121:18)
at getPathInAst (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:110:25)
at enterNode (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:121:18)
at getPathInAst (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:110:25)
at enterNode (C:\Users\fabriece\Documents\GitHub\hapi\orange\node_modules\webpack\lib\optimize\ConcatenatedModule.js:121:18)
Desired functionality.
Aot build without errors
Mention any other details that might be useful.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 14
- Comments: 40 (3 by maintainers)
I’m still getting this on @angular/cli 1.6.6.
@akhedrane Here is an open issue regarding this: https://github.com/angular/angular/issues/21809 They are working on a solution.
same here
@angular/cli: 1.3.0 node: 7.5.0 os: win32 x64 @angular/animations: 4.3.2 @angular/common: 4.3.2 @angular/compiler: 4.3.2 @angular/compiler-cli: 4.3.2 @angular/core: 4.3.2 @angular/forms: 4.3.2 @angular/http: 4.3.2 @angular/platform-browser: 4.3.2 @angular/platform-browser-dynamic: 4.3.2 @angular/platform-server: 4.3.2 @angular/router: 4.3.2 @angular/cli: 1.3.0
For me was related to the syntax of FormBuilder:
This shortcut sintax NOT works
This works
Problem solved to me
I am experiencing this issue in multiple projects using the latest CLI version (1.6.6).
As a workaround, I am avoiding the issue by disabling the build optimizer:
ng build --build-optimizer false
Enabling vendor-chunk solve the issue temporarly
ng build --prod --aot --vendor-chunk=true
Tested with: Angular CLI: 1.6.7 Angular: 5.2.3 Node: 9.3.0
I’m having this issue as well.
TypeError: Cannot read property 'range' of null
I tested with: Angular 5.2.2 and 5.2.1 Angular CLI 1.6.6
Downgrading all packaged from 5.2.2 to 5.2.1 works for me.
Same issue with cli 1.6.6 …
But works with
I had the same error but the problem was an unnecessary comma in validators array:
'city': [null, [Validators.required, , Validators.pattern(/[a-zA-Z\'\- ]/)]]
changed it to'city': [null, [Validators.required, Validators.pattern(/[a-zA-Z\'\- ]/)]]
and everything compiles withng build --prod --build-optimizer
As a note, if you switch to
module: 'commonjs'
instead ofmodule: 'es2015'
in yourtsconfig.app.json
, it will also fix this as a temporary workaround until https://github.com/angular/angular/pull/20624 (which simply changes locale modules tocommonjs
) is in.👍
ng build -prod --aot=false
👎
ng build -prod
tested with ngCli v1.6.6/v1.6.5 and angular v5.2.1
me too. if I downgraded Angular from 5.2.2 to 5.2.1 and it works. Other apps I’m working on do build with angular 5.2.2 and cli 1.6.6…
Facing same issue with 1.3.1 as well
This seems to be partly some sort of caching issue. I have it working on my development server. On the build server, I’ve reinstalled the global version of the @angular/cli to be 1.2.8 (same as on development), reinstalled all project node packages, and released. npm cache clear has been used. I have made sure both environments are using the same version of npm.
However, I get this error on the build server, but not on the development server.
I have seen the issue come up on development and both are now reverted to be using 1.2.8 of the cli, globally and within the project. This fixed the issue on development, but not on the build server,