ng服务不起作用 [英] ng serve does not work
问题描述
我以前有角度cli,但是我错误地用
重新安装了它
I used to have angular cli, but i mistakenly installed it again with
npm install -g angular-cli
现在我运行ng serve
时会抱怨:
It seems like you're using a project generated using an old version of the Angular CLI.
The latest CLI now uses webpack and includes a lot of improvements, include a simpler
workflow, a faster build and smaller bundles.
To get more info, including a step-by-step guide to upgrade the CLI, follow this link:
https://github.com/angular/angular-cli/wiki/Upgrading-from-Beta.10-to-Beta.12
当我尝试在另一个目录中使用ng new
创建新项目时,它抱怨:
when i try to create a new project using ng new
in another directory it complains that:
Cannot find module 'reflect-metadata'
那是什么问题?
推荐答案
关键是使 global 和 local Angular-cli版本相同.
The key is to have both global and local Angular-cli versions the same.
假设我们想将其固定为例如. 1.0.0-beta.15
.
Let's say we want to fixate it to eg. 1.0.0-beta.15
.
因此,您可以尝试在npm install -g angular-cli@1.0.0-beta.15
中修复该版本,并在您的package.json
中将其修复为相同的版本:"angular-cli": "1.0.0-beta.15"
.然后运行npm install --save-dev
.
So you can try to fixate the version in npm install -g angular-cli@1.0.0-beta.15
and in your package.json
fixate it to the same version: "angular-cli": "1.0.0-beta.15"
. Then run npm install --save-dev
.
当前,可以在NPM的@angular/cli
下而不是angular-cli
上找到Angular CLI.这是文档链接,说明如何卸载旧和安装最新版本的 CLI.
Currently Angular CLI can be found on NPM under @angular/cli
instead of angular-cli
. Here are links to documentation how to uninstall old and install the latest version of CLI.
这篇关于ng服务不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!