angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Ng Serve fails at 95% - TypeError: callbacks[i] is not a function

Open DanielStep opened this issue 8 years ago • 184 comments

Versions

Angular CLI: 1.6.8
Node: 9.5.0
OS: darwin x64
Angular: 5.2.4
@angular/cli: 1.6.8
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.8
@schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0

  MacOS High Sierra 10.13.3

Repro steps

MacBook-Pro:~ daniel$ ng new test-proj ... Installed packages for tooling via npm. Successfully initialized git. Project 'test-proj' successfully created.

MacBook-Pro:~ daniel$ cd test-proj/

MacBook-Pro:test-proj daniel$ npm install up to date in 6.008s

MacBook-Pro:test-proj daniel$ ng serve

Observed behavior

** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
 95% emitting/Users/daniel/test-proj/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:40
		callbacks[i](err, result);
		            ^

TypeError: callbacks[i] is not a function
    at Storage.finished (/Users/daniel/test-proj/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:40:15)
    at /Users/daniel/test-proj/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:77:9
    at /Users/daniel/test-proj/node_modules/graceful-fs/polyfills.js:287:18
    at FSReqWrap.oncomplete (fs.js:167:5)

Desired behavior

For build to be 100% successful and served to browser

DanielStep avatar Feb 08 '18 11:02 DanielStep

[email protected] didn't help

yfain avatar Feb 08 '18 13:02 yfain

clean project with ng new, all latest angular stuff, wont work either

officechuber avatar Feb 08 '18 13:02 officechuber

Same issue. I tested "npm install [email protected]" and it works for me. (localhost project)

MartinManchev avatar Feb 08 '18 13:02 MartinManchev

also ng test --code-coverage --single-run doesn't work anymore

TypeError: Cannot read property 'apply' of undefined

kevinclerc avatar Feb 08 '18 13:02 kevinclerc

lets go have a drink then come back :)

officechuber avatar Feb 08 '18 13:02 officechuber

Thanks @danielszenasi ! That worked for me. :)

mwarule avatar Feb 08 '18 13:02 mwarule

For anybody using Gitlab with yarn, you'll need to add a script line after "yarn install":

- npm install [email protected]

This fixed it for me

gamebenchjake avatar Feb 08 '18 13:02 gamebenchjake

Hi all,

@evilebottnawi is looking into this from the webpack side, and I am looking at it from the CLI side.

It seems to be a bad interaction in usage of the webpack file system. I don't yet have more details than that but we are looking into this.

There's already a couple of suggestions on how to work around for now but I will reiterate for visibility: you can try to force install [email protected] in your project.

Using npm, follow these steps:

I used npm 5.6.0 for this, and recommend you use at least that version as well since it has lockfile support and solves some npm problems with windows.

@kylecordes has also offered some advice for Yarn users in https://github.com/angular/angular-cli/issues/9550#issuecomment-364110779.

I'd like to remind everyone that you only have reproducible installs if you use a lockfile. Both NPM v5+ and Yarn support lockfiles. If your CI works one day but not the next and you did not change your code or package.json, it is likely because one of your dependencies had a bad release and you did not have a lockfile.

It is your responsibility as a library consumer to use lockfiles. No one wants to do a release with bugs but it sometimes happens, and the best we can do is to fix it as fast as possible with a new release. When you have a couple of thousand total dependencies it is only a matter of time until one of them has a bad release.

filipesilva avatar Feb 08 '18 13:02 filipesilva

Same Here!

capture

malikfaizanhaider avatar Feb 08 '18 13:02 malikfaizanhaider

Same problem.... version 1.6.7

regedit15 avatar Feb 08 '18 13:02 regedit15

@gamebenchjake 's solution worked for me. I found the answer here https://stackoverflow.com/questions/48684276/angular-cli-gives-me-typeerror-callbacksi-is-not-a-function-when-i-ng-serv

oudinia avatar Feb 08 '18 13:02 oudinia

npm install --save [email protected] Worked for us.

We are running Visual Studio Builds for Angular App. This is out setup:

image

anilbobba1 avatar Feb 08 '18 14:02 anilbobba1

Can anyone direct me to a resource that details implementing this fix on an Azure web app through VSTS?

skinnerjames avatar Feb 08 '18 14:02 skinnerjames

Workaround suggested by @MartinManchev worked fine for me!!

"npm install [email protected]"

venkatsub24 avatar Feb 08 '18 14:02 venkatsub24

Worked for me npm install [email protected] --save

florimm avatar Feb 08 '18 14:02 florimm

npm install [email protected] solve my issue

AbdulRayhman avatar Feb 08 '18 14:02 AbdulRayhman

I had the same problem, but the solution npm install [email protected] worked for me.

thanks @danielszenasi

ralflorent avatar Feb 08 '18 14:02 ralflorent

SAME ERROR HERE

Angular CLI: 1.6.7 Node: 6.9.4 OS: win32 x64 Angular: 5.2.4 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router

angular/cli: 1.6.7 angular-devkit/build-optimizer: 0.0.42 angular-devkit/core: 0.2.0 angular-devkit/schematics: 0.0.52 ngtools/json-schema: 1.1.0 ngtools/webpack: 1.9.7 schematics/angular: 0.1.17 typescript: 2.5.3 webpack: 3.10.0

alexnoise79 avatar Feb 08 '18 14:02 alexnoise79

Me too

Hofkey avatar Feb 08 '18 14:02 Hofkey

npm install package@version still adds semver ranges and didn't help in my case, so I used -E option to use an exact version. Additionally using option -O to add the plugin to peer dependencies only, as the webapp doesn't depend directly on copy-webpack-plugin. Solution described here: https://stackoverflow.com/a/48687139/3120193

michaelbazos avatar Feb 08 '18 14:02 michaelbazos