ng 服务不起作用 [英] ng serve does not work
问题描述
我以前有 angular cli,但我错误地重新安装了
I used to have angular cli, but i mistakenly installed it again with
npm install -g angular-cli
现在当我运行 ng serve
它抱怨:
and now when i run ng serve
it complains:
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
.
目前 Angular CLI 可以在 NPM 上的 @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屋!