For several hours now, I've been struggling to make npm run build:production
work. This command is included as part of my build process when a branch is pushed. However, I have encountered an issue with my package.json file that I haven't been able to resolve yet. It's worth mentioning that while ng build
works perfectly fine, the production build fails consistently.
To reproduce the issue:
rm -rf node_modules\
npm install
npm run build:production
Here is the content of my package.json file:
{
"name": "royal_competition",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:production": "ng build --prod",
"build:ssr": "ng run royal_competition:server:dev",
...
},
"private": true,
"dependencies": {
...
},
"devDependencies": {
...
},
"optionalDependencies": {
...
}
}
Below is the error output generated during the production build:
...
Compiling @angular/platform-server : es2015 as esm2015
Compiling @nguniversal/module-map-ngfactory-loader : es2015 as esm2015
An error occurred during the build:
Error: The Angular Compiler requires TypeScript >=4.2.3 and <4.3.0 but found version 4.3.2.
at checkVersion (C:\Users\ch33f\Documents\Projects\WebProjects\royalcompetition\royalcompetition\ClientApp\node_modules\@angular\compiler-cli\src\typescript_support.js:65:19)
...
An unhandled exception occurred: The Angular Compiler requires TypeScript >=4.2.3 and <4.3.0 but found version 4.3.2.
I attempted to modify the typescript version to v4.0, but it keeps reverting back to ^4.3.2
Any assistance on this matter would be highly appreciated. Thank you!
EDIT: Following Prakash's solution
npm i <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="295d50594c5a4a5b40595d691d071b071c">[email protected]</a> --save-dev --save-exact
, I managed to overcome one problem only to encounter another.
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js): SassError: no mixin named mat-core on line 10 of src/custom-theme.scss