如何为旧的 Angular 项目提供服务? [英] How to ng serve an older Angular project?

查看:22
本文介绍了如何为旧的 Angular 项目提供服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试ng serve一个包含在第三方框架中的示例 Angular 项目.从它的 package.json 文件来看,示例项目需要 Angular v~4.我的全局 CLI 版本是 6.0.8.该项目不包含 node_modules 文件夹,也不包含 angular-cli.jsonangular.json 文件.

I'm trying to ng serve a sample Angular project included in a third party framework. The sample project is wanting Angular v~4 judging from its package.json file. My global CLI version is 6.0.8. The project doesn't include a node_modules folder nor an angular-cli.json or angular.json file.

我怎样才能成功ng serve这个旧项目?

How can I successfully ng serve this older project?

我必须干预这个项目的 package.json 文件来更新版本号,还是我可以只安装本地 Angular CLI 的旧版本 ~4.0.3?

Must I meddle with this project's package.json file to update the version numbers, or can I instead just install the older version ~4.0.3 of local Angular CLI?

即便如此,一旦我安装了旧的 CLI 版本,我该如何通过 CLI 生成 angular-cli.json 文件?到目前为止,我只能让 node_modules 出现 - 而不是 angular-cli.jsonangular.json 文件.

And even then, once I install an older CLI version, how do I generate the angular-cli.json file via the CLI? So far I'm only able to get node_modules to appear - not an angular-cli.json or angular.json file.

推荐答案

我能够通过运行不同的命令来解决这个问题:npm run build.这似乎可以正确地为其所需版本提供应用程序.

I was able to get around this issue by running a different command: npm run build. This seemed to properly serve the app in its desired version.

这篇关于如何为旧的 Angular 项目提供服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆