[英]angular application breaking on installing a package
I have cloned an existing angular project.我已经克隆了一个现有的 angular 项目。 I did ng serve
and the application is running fine.我做了ng serve
并且应用程序运行良好。 I wanted to install signalR package.我想安装 signalR package。 I have executed我已经执行了
npm install @aspnet/signalr –-save
The package is installed successfully. package安装成功。 But then when I run ng serve
, the project has failed to compile with errors但是当我运行ng serve
时,该项目无法编译并出现错误
ERROR in ./src/app/PackageAdd.component.ts
Module not found: Error: Can't resolve 'json-diff' in 'C:\Users\Web\src\app\components'
ERROR in ./src/app/components/Update.modal.ts
Module not found: Error: Can't resolve 'json-diff' in 'C:\Users\Web\src\app\components'
ERROR in ./src/app/components/CreateEdit.component.ts
So I wanted to revert back to the initial state and tried to uninstall the package.所以我想恢复到最初的 state 并尝试卸载 package。 I tried with我试过了
npm uninstall @aspnet/signalr
and then did ng serve
but still see the same errors.然后ng serve
但仍然看到相同的错误。 I am not sure what to do now.我不知道现在该怎么办。 How do I revert back to the initial state where the application is getting compiled successfully and running.如何恢复到应用程序成功编译并运行的初始 state。
This doesn't seem to be an error from Signalr.这似乎不是 Signalr 的错误。 From the error you've provivded, I'm guessing there's a json-diff
npm package being used in your project (look in package.json
for it). From the error you've provivded, I'm guessing there's a json-diff
npm package being used in your project (look in package.json
for it).
If it's not supposed to be there (check the original code), remove the code related to json-diff
from the Update.modal.ts
and CreateEdit.component.ts
files.如果它不应该存在(检查原始代码),请从Update.modal.ts
和CreateEdit.component.ts
文件中删除与json-diff
相关的代码。
If it's supposed to be there, make sure it's listed in package.json (otherwise, install it).如果它应该在那里,请确保它在 package.json 中列出(否则,安装它)。 If it's already installed, delete the package-lock.json
file and the node_modules
folder, and run npm install
again.如果已经安装,请删除package-lock.json
文件和node_modules
文件夹,然后再次运行npm install
。
If everything fails, and you just want to revert to the original branch code, run git clean -fd && git reset --hard
(WARNING: this will remove all un-pushed local changes that you had done to the branch as well as new files that are not tracked by git).如果一切都失败了,并且您只想恢复到原始分支代码,请运行git clean -fd && git reset --hard
(警告:这将删除您对分支所做的所有未推送的本地更改以及新的git 不跟踪的文件)。 Confirm that the package-lock.json
and node_modules
folder are deleted in your project, and run npm install
确认您的项目中的package-lock.json
和node_modules
文件夹已删除,然后运行npm install
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.