簡體   English   中英

角構建失敗

[英]Angular Build is getting failed

我有與Angular構建相關的問題。 以下是我對package.json文件的依賴

"dependencies": {
"@angular/animations": "^6.1.10",
"@angular/common": "^6.1.0",
"@angular/compiler": "^6.1.0",
"@angular/core": "^6.1.0",
"@angular/forms": "^6.1.0",
"@angular/platform-browser": "^6.1.0",
"@angular/platform-browser-dynamic": "^6.1.0",
"@angular/router": "^6.1.0",
"@fortawesome/angular-fontawesome": "^0.3.0",
"@fortawesome/fontawesome-svg-core": "^1.2.17",
"@fortawesome/free-solid-svg-icons": "^5.8.1",
"@ng-select/ng-select": "^2.15.3",
"@ngtools/webpack": "^6.2.9",
"alertifyjs": "^1.11.2",
"bootstrap": "^4.1.1",
"core-js": "^2.5.4",
"d3": "^5.9.2",
"jquery": "^3.4.1",
"ngx-bootstrap": "^3.1.3",
"ngx-toastr": "^9.1.2",
"nyc": "^14.1.1",
"popper.js": "^1.15.0",
"rxjs": "^6.2.2",
"rxjs-compat": "^6.4.0",
"zone.js": "~0.8.26"},


"devDependencies": {
"@angular-devkit/build-angular": "~0.8.0",
"@angular/cli": "~6.2.3",
"@angular/compiler-cli": "^8.2.0",
"@angular/language-service": "^6.1.0",
"@types/d3": "^5.7.1",
"@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.1.0",
"karma-chrome-launcher": "~2.2.0",
"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.3"}

我正在嘗試使用npm start運行應用程序,這會向我返回錯誤,例如,

找不到API編譯器CLI,函數VERSION

Error: Could not find API compiler-cli, function VERSION
    at _error (D:\Ketan\Projects\myproject\node_modules\@ngtools\webpack\src\ngtools_api.js:8:11)
    at getApiMember (D:\Ketan\Projects\myproject\node_modules\@ngtools\webpack\src\ngtools_api.js:11:32)
    at Object.<anonymous> (D:\Ketan\Projects\myproject\node_modules\@ngtools\webpack\src\ngtools_api.js:50:19)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (D:\Ketan\Projects\myproject\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:28:23)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myproject@0.0.0 start: `ng serve --proxy-config proxy.conf.json`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myproject@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ketan.jariwala\AppData\Roaming\npm-cache\_logs\2019-08-02T10_58_01_702Z-debug.logCould not find API compiler-cli, function VERSION
Error: Could not find API compiler-cli, function VERSION
    at _error (D:\Ketan\Projects\myproject\node_modules\@ngtools\webpack\src\ngtools_api.js:8:11)
    at getApiMember (D:\Ketan\Projects\myproject\node_modules\@ngtools\webpack\src\ngtools_api.js:11:32)
    at Object.<anonymous> (D:\Ketan\Projects\myproject\node_modules\@ngtools\webpack\src\ngtools_api.js:50:19)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (D:\Ketan\Projects\myproject\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:28:23)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myproject@0.0.0 start: `ng serve --proxy-config proxy.conf.json`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myproject@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ketan.jariwala\AppData\Roaming\npm-cache\_logs\2019-08-02T10_58_01_702Z-debug.logCould not find API compiler-cli, function VERSION
Error: Could not find API compiler-cli, function VERSION
    at _error (D:\Ketan\Projects\myproject\node_modules\@ngtools\webpack\src\ngtools_api.js:8:11)
    at getApiMember (D:\Ketan\Projects\myproject\node_modules\@ngtools\webpack\src\ngtools_api.js:11:32)
    at Object.<anonymous> (D:\Ketan\Projects\myproject\node_modules\@ngtools\webpack\src\ngtools_api.js:50:19)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (D:\Ketan\Projects\myproject\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:28:23)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myproject@0.0.0 start: `ng serve --proxy-config proxy.conf.json`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myproject@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

請幫忙! 提前致謝!

請嘗試以下給定的命令:

npm i --save-dev @angular/cli @angular-devkit/build-angular @angular/compiler @angular/compiler-cli

它將安裝在給定的軟件包之上。

然后,您需要執行npm startng serve

首先,您必須刪除node_module。 然后清除npm緩存。

https://www.npmjs.com/package/@angular/core

https://www.npmjs.com/package/@angular/cli

npm cache clean --verify --force
npm install -g @angular/cli
npm i @angular/core
npm install 

cli版本和cli-cli版本之間存在一些版本差異。 全局卸載每個模塊。 清除緩存,然后重新安裝所有模塊。

$ npm uninstall -g @angular/cli @angular-devkit/build-angular @angular/compiler @angular/compiler-cli
$ npm cache clean
$ npm install --save-dev @angular/cli @angular-devkit/build-angular @angular/compiler @angular/compiler-cli

還要檢查tslib是否必須添加到package.json文件中

"dependencies": {
    ["tslib": "^1.9.0"]
}

並重復以上步驟。 祝好運!

您可以使用這些命令來查看它是否有效。

npm uninstall angular-cli -g
npm uninstall angular-cli --save
npm install -g @angular/cli
npm install @angular/cli --save
npm install @angular/compiler-cli --save

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM