Angular-cli: Could not find API compiler-cli, function VERSION

Created on 1 Jun 2018  Â·  9Comments  Â·  Source: angular/angular-cli

I tried to run ng serve but it throws me this error:
Could not find API compiler-cli, function VERSION
Error: Could not find API compiler-cli, function VERSION
at _error (/node_modules/@ngtools/webpack/src/ngtools_api.js:8:11)
at Object. (/node_modules/@ngtools/webpack/src/ngtools_api.js:49:8)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:23:23)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)

And my my package.jason files are:
{
"name": "app6",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.0.2",
"@angular/cdk": "^5.0.0-rc.1",
"@angular/common": "^5.0.2",
"@angular/compiler": "^5.0.2",
"@angular/core": "^5.0.2",
"@angular/forms": "^5.0.2",
"@angular/http": "^5.0.2",
"@angular/material": "^5.0.0-rc.1",
"@angular/platform-browser": "^5.0.2",
"@angular/platform-browser-dynamic": "^5.0.2",
"@angular/router": "^5.0.2",
"core-js": "^2.5.1",
"fuse.js": "^3.2.0",
"hammerjs": "^2.0.8",
"ng2-toasty": "^4.0.3",
"npm": "^6.1.0",
"rxjs": "^5.5.2",
"ts-helpers": "^1.1.1",
"zone.js": "^0.8.18"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.6",
"@angular-devkit/core": "^0.7.0-beta.1",
"@angular/cli": "^6.0.7",
"@angular/compiler-cli": "^5.0.2",
"@types/bootstrap": "^3.3.36",
"@types/jasmine": "^2.8.2",
"@types/jquery": "^3.2.16",
"@types/node": "^8.0.53",
"bootstrap": "^3.3.7",
"codelyzer": "^4.0.1",
"jasmine-core": "^2.8.0",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.6.0",
"protractor": "^5.2.0",
"ts-node": "^3.3.0",
"tslint": "^5.8.0",
"typescript": "^2.4.2"
}
}

and I am using following angular version
troy@dragon:~/pos-pelzhing$ ng --version

 _                      _                 ____ _     ___
/ \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|

/ â–³ \ | '_ \ / _| | | | |/ _ | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ __| |_|__, |__,_|_|__,_|_| ____|_____|___|
|___/

Angular CLI: 6.0.7
Node: 8.11.2
OS: linux x64
Angular: 5.0.2
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.6.7
@angular-devkit/build-angular
@angular-devkit/core 0.7.0-beta.1
@angular-devkit/schematics 0.6.7
@angular/cdk 5.0.0-rc.1
@angular/cli 6.0.7
@angular/material 5.0.0-rc.1
@schematics/angular 0.6.7
@schematics/update 0.6.7
rxjs 5.5.2
typescript 2.4.2

ngtoolwebpack

Most helpful comment

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

All 9 comments

FWIW, the relevant code is as below in (this source file)[https://github.com/angular/angular-cli/blob/44086c60ff1d6c26d30850bef125120f6c498ac1/packages/ngtools/webpack/src/ngtools_api.ts]:

compilerCli = require('@angular/compiler-cli');

export const VERSION: typeof ngc.VERSION =
  compilerCli
  && compilerCli.VERSION
  || _error('compiler-cli', 'VERSION');

TO make a long story short, I found out the problem was that the tslib package could not be found. The packager should have installed (I use lerna), but did not for some reason. In other repos it is correctly installed under @angular/compiler-cli. I solved this problem by manually adding tslib to the package.json file.

Since we two are probably not the only ones to run into this problem, I would hope that the developers would improve this error message a bit somehow.

I solved it by upgrade @angular/cli, @angular/compiler and @angular/compiler-cli to version 6 even if angular version is lesser.

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

If someone happens to be creating a custom builder for Angular project, know that you get this error by npm linking to your builder's package. Running ng <architect>, it breaks when trying to get the builderPaths in angular-devkit/architect. Happened to me, fixed it by moving the package to node_modules.

FWIW, the relevant code is as below in (this source file)[https://github.com/angular/angular-cli/blob/44086c60ff1d6c26d30850bef125120f6c498ac1/packages/ngtools/webpack/src/ngtools_api.ts]:

compilerCli = require('@angular/compiler-cli');

export const VERSION: typeof ngc.VERSION =
  compilerCli
  && compilerCli.VERSION
  || _error('compiler-cli', 'VERSION');

TO make a long story short, I found out the problem was that the tslib package could not be found. The packager should have installed (I use lerna), but did not for some reason. In other repos it is correctly installed under @angular/compiler-cli. I solved this problem by manually adding tslib to the package.json file.

Since we two are probably not the only ones to run into this problem, I would hope that the developers would improve this error message a bit somehow.

I faced with same issue, all I did is just installed @angular/compiler-cli peerDependencies.

Thanks for reporting this issue. This issue was originally reported a long time ago and since then we've had many releases, one of which might have addressed this problem. Please update to the most recent Angular CLI version.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

I solved it by upgrade @angular/cli, @angular/compiler and @angular/compiler-cli to version 6 even if angular version is lesser.

Thanks minato-namikaze

I have followed the same but not working till now. I have provided the error I am getting here below:

Could not find API compiler-cli, function VERSION Error: Could not find API compiler-cli, function VERSION at _error (C:\xampp\htdocs\angular\ng6-app1\node_modules\@ngtools\webpack\src\ngtools_api.js:8:11) at getApiMember (C:\xampp\htdocs\angular\ng6-app1\node_modules\@ngtools\webpack\src\ngtools_api.js:11:32) at Object.<anonymous> (C:\xampp\htdocs\angular\ng6-app1\node_modules\@ngtools\webpack\src\ngtools_api.js:50:19) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object.<anonymous> (C:\xampp\htdocs\angular\ng6-app1\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:28:23) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3)

Any help will be appriciated :)

My angular version is 6.2.9

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gotschmarcel picture gotschmarcel  Â·  3Comments

MateenKadwaikar picture MateenKadwaikar  Â·  3Comments

daBishMan picture daBishMan  Â·  3Comments

sysmat picture sysmat  Â·  3Comments

naveedahmed1 picture naveedahmed1  Â·  3Comments