简体   繁体   中英

How to undo Angular 2 Cli ng-eject?

I have just executed the ng eject command. But now I need to revert it, and continue to use ng commands. Is it possible?

I would be grateful for any help.

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
}

使用当前版本的angular cli,您需要标记弹出:false或删除文件angular-cli.json文件中的弹出属性而不是package.json文件

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM