[英]How to undo Angular 2 Cli ng-eject?
I have just executed the ng eject
command. 我刚刚执行了
ng eject
命令。 But now I need to revert it, and continue to use ng
commands. 但现在我需要还原它,并继续使用
ng
命令。 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: 在https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/tasks/build.ts#L27 (当前角度CLI版本:1.0.1)有一个条件:
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 : 当你运行
ng-eject
,使用新的npm脚本修改package.json文件,添加或替换webpack.config.js文件,并将弹出的标志添加到.angular.cli.json :
"project": {
"name": "YOUR PROJECT NAME",
"ejected": true
},
So, just remove "ejected" flag from your .angular.cli.json file: 因此,只需从.angular.cli.json文件中删除“弹出”标志:
or change this flag to false
: 或将此标志更改为
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. 此命令使构建配置成为项目的一部分并摆脱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.
并设置“弹出”:在angular-cli.json文件中为true,在项目根目录中创建新文件webpack.config.js,并在package.json中修改运行脚本。
Finally, to undo the ng-eject command it is necessary to modify the package.json file again 最后,要撤消ng-eject命令,必须再次修改package.json文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.