简体   繁体   English

从 Git 存储库克隆后,Angular 应用程序将无法运行

[英]Angular App won't run after Cloning from a Git Repository

I recently completed the Angular Tour of Heroes tutorial (with some slight modifications) and it all works fantastically well.我最近完成了 Angular Tour of Heroes 教程(稍作修改),一切都非常好。 I then wanted to try push it up to a GIT repo in VSTS, and then clone it to another machine and run it from there.然后我想尝试将它推送到 VSTS 中的 GIT 存储库,然后将其克隆到另一台机器并从那里运行它。 Unfortunately now I've cloned it to the new machine I'm unable to get it running.不幸的是,现在我已将其克隆到新机器上,但无法运行。 Both ng serve --open and ng build fail. ng serve --open 和 ng build 都失败了。

Originally it was complaining about missing "@angular-devkit/build-angular" so I went ahead and installed that, unfortunately on the next build attempt there was another issue最初它抱怨缺少“@angular-devkit/build-angular”所以我继续安装它,不幸的是在下一次构建尝试中还有另一个问题

"Cannot find module '@angular-devkit/build-optimizer'" “找不到模块‘@angular-devkit/build-optimizer’”

Is it going to be the case that I need to reinstall every dependency every time I clone a solution using Angular or Node, or is there a simple command I'm missing here?是不是每次我使用 Angular 或 Node 克隆解决方案时都需要重新安装每个依赖项,或者我在这里遗漏了一个简单的命令?

Google suggested I try "npm install -g npm-install-missing" and "npm rebuild", unfortunately neither helped.谷歌建议我尝试“npm install -g npm-install-missing”和“npm rebuild”,不幸的是都没有帮助。

After cloning the project just follow the instructions.克隆项目后,只需按照说明进行操作。

cd 'your project name...'

And then install the packages and dependencies.然后安装包和依赖项。

npm install

and then you can run the project by running this code.然后您可以通过运行此代码来运行该项目。

ng serve

This should work fine.这应该可以正常工作。

您需要在服务前进行npm install

The issue looks like it was caused as I cloned my project to a sub folder of my VS workspace instead of the root.该问题似乎是由于我将项目克隆到 VS 工作区的子文件夹而不是根目录而引起的。 Once I cleared out the entire folder, recloned at the root, and then run npm install, everything worked fine.一旦我清除了整个文件夹,在根目录重新克隆,然后运行 ​​npm install,一切正常。

Hey I was facing the same issue and It got resolved using the below written method type this command in your cmd: npm install -g npm@latest嘿,我遇到了同样的问题,它使用下面的书面方法解决了,在你的 cmd 中输入这个命令:npm install -g npm@latest

then clone your repository then run npm install and npm update then ng serve然后克隆您的存储库,然后运行 ​​npm install 和 npm update 然后运行 ​​ng serve

Go to your Project folder -转到您的项目文件夹 -

cd c:/MYProjectFolder cd c:/MYProjectFolder

install packages by running -通过运行安装软件包 -

npm install安装

finally -最后 -

ng serve --o ng服务--o

on your terminal make sure you are on the cloned project directory.在您的终端上,确保您位于克隆的项目目录中。 if not cd into it如果没有 cd 进去

cd <project-name>

then install the packages used by running this command on your terminal;然后在终端上安装通过运行此命令使用的软件包;

npm install

after successful install you can now serve by running;成功安装后,您现在可以通过运行提供服务;

ng s --o

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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