I'm facing an issue with an old Angular project that I'm trying to build. After pulling down the code, running npm install
@angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fc9f9095bccdd2cbd2c8">[email protected]</a>
, and attempting to build using ng build, I encountered the following error:
The versions of @angular/compiler-cli and typescript could not be determined. The most common reason for this is a broken npm install.
To resolve this issue, please ensure that your package.json includes both @angular/compiler-cli and typescript in devDependencies. Then delete node_modules and package-lock.json (if it exists) before running npm install again.
My concern is about the cli version mentioned as 1.7.4, which seems incorrect as angular/cli is not listed in the package.json file. How can I fix this issue without modifying the existing code?
Update:
I have now added @angular/[email protected] and [email protected] to the devDependencies. I have also included the updated package.json. However, the new error message states:
Unable to locate any apps in
.angular-cli.json
.
This occurs because I do not have a .angular-cli.json file. Can someone tell me the latest version of angular cli that does not require this file?
Update 2:
I created an .angular-cli.json file and attempted to build the project. After making some JSON file adjustments, I encountered a mysterious error:
TypeError: Cannot read property 'length' of undefined
This seems to originate from an older version of cli/compiler/typescript. How can I identify the root cause of this error?
If I start updating the cli and other dependencies, it might lead to problems since transitioning to Angular 7.2 would require extensive code changes. (I attempted this previously but gave up after one day.)
package.json:
"dependencies": {
"@angular/cli": "^1.7.4",
"@angular/common": "^2.4.5",
...
},
"devDependencies": {
"@angular/compiler-cli": "^2.4.5",
...
}