[Fixed] ng build –prod failed after ag-grid v 22.1.1 upgrade


I’ve started using since its version 18 and currently at 20.0.0

I am in the process of upgrading to its latest version – 22.1.1.

After resolving warning/errors due to breaking changes, everything – including ‘ng serve’ works fine.

However, when I try to build angular application in prod mode, it fails.

ERROR in ./app/app.module.ngfactory.js
Module not found: Error: Can’t resolve ‘ag-grid-community/dist/lib/eventService’ in ‘C:\project\src\app’ERROR in ./main.ts
Module not found: Error: Can’t resolve ‘ag-grid-enterprise/main’ in ‘C:\project\src’

Below is the console log I get. Could anyone please help?

PS C:\projectDirectory> npm run build:prod

> [email protected] build:prod <C:\projectDirectory>
> node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build --prod --base-href ./

Browserslist: caniuse-lite is outdated. Please run next command `npm update`

Date: 2020-02-06T14:34:51.950Z
Hash: f5504506298058ba661b
Time: 303119ms
chunk {0} runtime.0feced4b926ef4569891.js (runtime) 2.35 kB [entry] [rendered]
chunk {1} 1.ff56049eefdf00546e5b.js () 20.1 kB [rendered]
chunk {2} common.778967e60acae82560b8.js (common) 1.59 kB [rendered]
chunk {3} 3.c9c6f4b4ee31655957c5.js () 68.6 kB [rendered]
chunk {4} 4.cd47c0ed33945d8a2cd1.js () 65.8 kB [rendered]
chunk {5} main.9f72bd0e6a2ce7cabf09.js (main) 1.13 MB [initial] [rendered]
chunk {6} polyfills.8c9e800099caebde3f97.js (polyfills) 151 kB [initial] [rendered]
chunk {7} polyfills-es5.1ecef396b36e47074889.js (polyfills-es5) 68.1 kB [initial] [rendered]
chunk {8} styles.40f4753a24be96f0632d.css (styles) 353 kB [initial] [rendered]
chunk {9} vendor.62a5b62a3c39ede2ff2f.js (vendor) 6.34 MB [initial] [rendered]
chunk {10} 10.36d9b310fedf245aa212.js () 123 kB [rendered]
chunk {11} 11.7f7517540c764751bd2c.js () 1.62 MB [rendered]
chunk {12} 12.79a7ea4d472beb37c285.js () 88.8 kB [rendered]
chunk {13} 13.4c9f9392997233b09d52.js () 318 kB [rendered]
chunk {14} 14.62996cef37bc77009502.js () 146 kB [rendered]
chunk {scripts} scripts.8af46854aabf37ded6dd.js (scripts) 125 kB [entry] [rendered]
ERROR in ./app/app.module.ngfactory.js
Module not found: Error: Can't resolve 'ag-grid-community/dist/lib/eventService' in 'C:\project\src\app'ERROR in ./main.ts
Module not found: Error: Can't resolve 'ag-grid-enterprise/main' in 'C:\project\src'
npm ERR! errno 1
npm ERR! [email protected] build:prod: `node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build --prod --base-href ./`


Seems you missed few things from migration guide.

Yes, it’s not obvious but you need to change packages for that update.

Long story short: you have to use new packages started from 22.0.0

Wrong :

"ag-grid-angular": "22.1.1",
"ag-grid-community": "22.1.1",
"ag-grid-enterprise": "22.1.1"


"@ag-grid-community/all-modules": "22.1.1",
"@ag-grid-community/angular": "22.1.1",
"@ag-grid-community/core": "22.1.1",
"@ag-grid-enterprise/all-modules": "22.1.2"

Leave a Reply

(*) Required, Your email will not be published