Upon completing the upgrade of my Angular2 project to Angular4 by executing the following command:
npm install @angular/common@latest @angular/compiler@latest @angular/compiler-cli@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/platform-server@latest @angular/router@latest @angular/animations@latest typescript@latest --save
An error message pops up when I run ng build --prod
:
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'D:\workspace\MyProject\src'
@ ./src/main.ts 4:0-74
@ multi ./src/main.ts
Interestingly, without the --prod
flag no errors are reported. While there are similar queries on stackoverflow, none seem to address this specific issue post-upgrading to Angular4.
Here's an excerpt from my package.json file:
{
"name": "MyProject",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
// List of dependencies...
},
"devDependencies": {
// List of dev-dependencies...
}
}
Edit. Below is a snippet of the project.json generated through ng new
with the latest CLI version:
{
"name": "mypro",
"version": "0.0.0",
"license": "MIT",
"scripts": {
// Project scripts...
},
"private": true,
"dependencies": {
// Latest dependencies...
},
"devDependencies": {
// Latest development dependencies...
}
}
Any insights or suggestions?