Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to undo Angular 2 Cli ng-eject?

At https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/tasks/build.ts#L27 (current angular CLI version: 1.0.1) there is a condition:

if (config.project && config.project.ejected) {
  throw new SilentError('An ejected project cannot use the build command anymore.');
}

when you run ng-eject, package.json file is modified with new npm scripts, webpack.config.js file is added or replaced and ejected flag is added to your .angular.cli.json:

"project": {
  "name": "YOUR PROJECT NAME",
  "ejected": true
},

So, just remove "ejected" flag from your .angular.cli.json file:

or change this flag to false:

"project": {
  "name": "YOUR PROJECT NAME",
  "ejected": false
}

With current version of angular cli you need to mark ejected:false or remove the ejected property inside file angular-cli.json file instead of package.json file


This command makes the build configuration part of your project and gets rid of Angular CLI. And also set “ejected”: true in angular-cli.json file , create new file webpack.config.js in project root, and modified run scripts in package.json.

Finally, to undo the ng-eject command it is necessary to modify the package.json file again