node --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
我列出了全局依赖项
npm list -g --depth=0
我知道
+-- @angular/cli@7.3.5
我检查其版本
ng --version
我使用的是旧版本6.2.8,而不是7.3.5。 这个旧版本从哪里来?我在一个空目录中。
Angular CLI: 6.2.8
Node: 10.14.2
OS: win32 x64
Angular:
当我使用
生成新项目时 ng new newapp
在我的package.json中,我有旧版本的@ angular-cli 6.2.8和angular 6.1.0
{
"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?
我在做什么错了?
答案 0 :(得分:0)
我建议立即执行以下命令并检查
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@latest
答案 1 :(得分:0)
感谢您的快速解答,但我遇到了同样的问题。 这是我遵循的步骤:
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版本。 但是按照开始时说明的步骤,情况似乎并非如此。