Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
763 views
in Technique[技术] by (71.8m points)

webpack - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...