我将Angular 4项目文件夹从拍卖生活重命名为拍卖05生活,并将以下三个旧项目名称替换为:
> angular-cli.json第4行
> app.e2e-spec.ts第3行
> package.json第2行
然后我跑了服务并得到了这个:
You seem to not be depending on “@angular/core”. This is an error.
编辑:按照下面评论中的说明,我重新启动终端窗口,确保我在正确的项目文件夹auction-05-life,运行npm install然后运行ng服务,这次有一个不同的例外:
module.js:471 throw err; ^ Error: Cannot find module 'heimdalljs-logger' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) ...
解决方法
在撰写本文时,Angular-cli命令行不进行重命名.
所以,这就是我所做的(手动):
所以,这就是我所做的(手动):
1.首先,通过搜索“旧名称”来了解旧名称在项目中的投入.在Linux上,我使用简单的grep作为.
grep -ir "oldname" .
这显示了很多文件,其中大多数在/ node_modules下.所以我删除了/ node_modules(在完成重命名后将使用npm install).
2.接下来,我做了Linux发现&将命令替换为当前文件夹中的文件,如下所示(源位于底部):
cd your folder sed -i 's/oldName/newName/g' *
请注意
**学分:
查找替换“sed”命令来自:
How to replace a string in multiple files in linux command line