Reputation: 211
I just make a migration from angular 5 to angular 7. After that i can't run the project. When I type ng serve I get this error:
The serve command requires to be run in an Angular project, but a project definition could not be found.
Here is my package.json
:
dependencies": {
"@angular/animations": "7.1.3",
"@angular/common": "7.1.3",
"@angular/compiler": "7.1.3",
"@angular/core": "7.1.3",
"@angular/forms": "7.1.3",
"@angular/http": "7.1.3",
"@angular/platform-browser": "7.1.3",
"@angular/platform-browser-dynamic": "7.1.3",
"@angular/router": "7.1.3",
"@ng-idle/core": "^2.0.0-beta.15",
"@ng-idle/keepalive": "^2.0.0-beta.15",
"@ngrx/store": "^5.2.0",
"angular2-chartjs": "^0.5.1",
"angular2-draggable": "^1.4.2",
"angular2-moment": "^1.9.0",
"bootstrap": "^4.0.0-beta.2",
"core-js": "^2.4.1",
"datejs": "^1.0.0-rc3",
"file-saver": "^2.0.0-rc.3",
"font-awesome": "^4.7.0",
"install": "^0.12.2",
"jquery": "^3.3.1",
"jspdf": "^1.4.1",
"ngx-cookie-service": "^1.0.10",
"ngx-treeview": "^6.0.1",
"popper.js": "^1.14.3",
"rxjs": "^6.3.3",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/cli": "7.1.3",
"@angular/compiler-cli": "7.1.3",
"@angular/language-service": "7.1.3",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/jspdf": "^1.1.31",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.4.1",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "3.1.6"
}
Does someone have an idea?
Thanks in advance
Upvotes: 0
Views: 5465
Reputation: 2087
Update the angular 5 to angular 7 please follows the below steps:-
Make sure NodeJS version is 8.9+ if not update it.
sudo npm install n -g
sudo n stable
sudo n latest
Update Angular cli globally and locally, and migrate the old configuration .angular-cli.json to the new angular.json format by running the following:
npm install -g @angular/cli
npm install @angular/cli
ng update @angular/cli
Update all of your Angular framework packages to v7,and the correct version of RxJS and TypeScript by running the following:
ng update @angular/core
Update Angular Material to the latest version by running the following:
ng update @angular/material
There are no breaking changes in Angular itself but they are in RxJS, so don't forget to use rxjs-compat library to work with legacy code.
npm install --save rxjs-compat
After update all packages, so remove the package.lock.json and node_module. And run the these command:-
npm install
Hope its work for you. Refer https://update.angular.io/ for more detailed guide.
Upvotes: 0
Reputation: 2078
As mentioned above please use https://update.angular.io/ update guides to update your app.
I would like to add something to the answer. The error occurs because of an incorrect update, There won't be an angular.json file in your project. I have noticed that even after running ng update @angular/cli command and following all the steps at https://update.angular.io/ this issue occurs,
During installation(update) Check in the terminal, whether the installation was successful or not if there is any error fix them.
remove package-lock.json & node_modules, npm cache verify, update global angular cli as well reinstall angular/cli, update cli
Upvotes: 1
Reputation: 7682
when upgrading from 5 to 7, angular changed it's cli configuration format.
angular-cli.json
-> angular.json
But doing the update the manual way isn't the preferred way.
The best way is to use the cli to do the updating for you. This web page will help you:
But basically you install angular cli globally
npm i -g @angular/cli
then run
ng update @angular/cli
ng update @angular/core
Upvotes: 3