节点 - version
v10.14.2
NPM版本
6.4.1
首先, @angular-cli未安装
ng -version
'ng' is not recognized as an internal or external command
我安装了最新版本的Angular:
npm install -g @angular/cli
i列出全局依赖项
npm list -g --depth=0
我得到
+-- @angular/cli@7.3.5
我检查其版本
ng --version
我没有版本7.3.5旧版本6.2.8。这个旧版本来自哪里?我在一个空的目录中。
Angular CLI: 6.2.8
Node: 10.14.2
OS: win32 x64
Angular:
当我用
生成一个新项目时 ng new newapp
在我的软件包中。
{
"name": "newapp",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^6.1.0",
"@angular/common": "^6.1.0",
"@angular/compiler": "^6.1.0",
"@angular/core": "^6.1.0",
"@angular/forms": "^6.1.0",
"@angular/http": "^6.1.0",
"@angular/platform-browser": "^6.1.0",
"@angular/platform-browser-dynamic": "^6.1.0",
"@angular/router": "^6.1.0",
"core-js": "^2.5.4",
"rxjs": "~6.2.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.8.0",
"@angular/cli": "~6.2.8",
"@angular/compiler-cli": "^6.1.0",
"@angular/language-service": "^6.1.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.3.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~2.9.2"
}
}
如何生成 @Angular-CLI项目版本7或8?我做错了什么?
感谢您的快速答案,但我遇到了同样的问题。这是我遵循的步骤:
npm uninstall -g @angular/cli
npm cache verify
npm list --depth -g
empty
ng -v
'ng' is not recognized as an internal or external command,
npm install -g @angular/cli@latest
npm list --depth -g
+-- @angular/cli@7.3.5
ng -v
Angular CLI: 6.2.8
因此,它列出为7.3.5,但是当我做NG -V时,我有6.2.8版在我拥有6.2.8版之前。这意味着也许剩余的6.2.8版本。但是,通过一开始说明的步骤,它似乎并非如此。
我建议现在按照以下命令进行检查
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@latest