我正在尝试安装并运行我的第一个Angular 6程序,但是在执行“ npm install”之后,出现此错误
package.json文件
{
"name": "ang66",
"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",
"ajv": "^6.10.2",
"core-js": "^2.5.4",
"rxjs": "~6.2.0",
"webpack": "^4.39.3",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.8.0",
"@angular/cli": "~6.2.9",
"@angular/compiler-cli": "^8.2.3",
"@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": "^4.3.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": "~3.5"
}
}
ng serve Could not find API compiler-cli, function VERSION Error: Could not find API compiler-cli, function VERSION at _error (C:\Users\NIIT.LAP-RKT-0X52602\Desktop\prog\web\ang\ang66\node_modules\@ngtools\webpack\src\ngtools_api.js:8:11) at getApiMember (C:\Users\NIIT.LAP-RKT-0X52602\Desktop\prog\web\ang\ang66\node_modules\@ngtools\webpack\src\ngtools_api.js:11:32) at Object.<anonymous> (C:\Users\NIIT.LAP-RKT-0X52602\Desktop\prog\web\ang\ang66\node_modules\@ngtools\webpack\src\ngtools_api.js:50:19) at Module._compile (module.js:653:30) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:566:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3) at Module.require (module.js:597:17) at require (internal/module.js:11:18) at Object.<anonymous> (C:\Users\NIIT.LAP-RKT-0X52602\Desktop\prog\web\ang\ang66\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:28:23) at Module._compile (module.js:653:30) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:566:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3)
答案 0 :(得分:0)
对我有用:
npm install typescript@3.5.3
npm install @angular/compiler@8.2.3
npm install ajv@^6.1
npm uninstall @angular/platform-browser-dynamic
npm install @angular/platform-browser-dynamic
答案 1 :(得分:-1)
尝试升级@ angular / cli,@ angular / compiler和@ angular / compiler-cli。
npm i --save-dev @angular/cli @angular-devkit/build-angular @angular/compiler @angular/compiler-cli