44

I literally just made a fresh installation of the Angular CLI in order to try it out and I don't have a clue on what's causing the following error on the command line:

    PC:cobros Fran$ ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
 95% emitting/Users/Fran/Documents/Workspace/Repos/cobros/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:40
        callbacks[i](err, result);
                    ^

TypeError: callbacks[i] is not a function
    at Storage.finished (/Users/Fran/Documents/Workspace/Repos/cobros/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:40:15)
    at /Users/Fran/Documents/Workspace/Repos/cobros/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:77:9
    at /Users/Fran/Documents/Workspace/Repos/cobros/node_modules/graceful-fs/polyfills.js:287:18
    at FSReqWrap.oncomplete (fs.js:153:5)

This is the information I get returned when I try "ng -v" (In case it's useful at all):

Angular CLI: 1.6.8
Node: 8.9.0
OS: darwin 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.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

What does the 'enhanced-resolve' module even do? Did I install angular wrong? I followed the instructions from https://github.com/angular/angular-cli and made sure I fulfilled the prerequisites.

R. Richards
  • 24,603
  • 10
  • 64
  • 64
Franco Roura
  • 807
  • 8
  • 26

12 Answers12

31

EDIT: The issue is now fixed, so there is no need to use this workaround anymore.


Solution (workaround) found here

Add "copy-webpack-plugin": "4.3.0" to your package.json

Thanks @neshkatrapati

parik
  • 2,313
  • 12
  • 39
  • 67
Rafa Garés
  • 305
  • 3
  • 6
7

I had same problem and this command did miracle for me

npm install copy-webpack-plugin@4.3.1
Daniel Chikaka
  • 1,432
  • 4
  • 17
  • 28
5

EDIT: The issue is now fixed, so there is no need to use this workaround anymore.


Happens after upgrading @angular/cli to 1.6.8.

Solution: Problem is with copy-webpack-plugin (https://github.com/webpack-contrib/copy-webpack-plugin/issues/217) npm i copy-webpack-plugin@4.3.1 --save-dev helps

NOTE: Previous offered solution was to downgrade cli to 1.6.7, which does not help.

Skorunka František
  • 5,102
  • 7
  • 44
  • 69
5

This issue should now be resolved with v4.4.1 released just now. https://github.com/webpack-contrib/copy-webpack-plugin/releases/tag/v4.4.1

Tarang
  • 318
  • 1
  • 10
1

As stated here https://github.com/angular/angular-cli/issues/9550 it's a problem with copy-webpack-plugin.

It can be solved by doing npm install copy-webpack-plugin@4.3.0

kikus
  • 31
  • 3
0

Following github.com/angular/angular-cli/issues/9550 (thanks @oers for the link in the comments)

I just downgraded Anuglar CLI to version 1.6.7.

To do so, just type

npm uninstall -g @angular/cli

And once it finished install a previous version

npm install -g @angular/cli@1.6.7

NOTE: This will work but it is just a temporary solution, they probably -and hopefully- hot fix this.

EDIT: Actually I tried the wrong project which wasn't using CLI, tried again and it doesn't work, if you follow the github thread, it looks like a big thing, as it doesn't work with CLI 1.5.x nor 1.6.x (didn't tried with the others). It looks like the only thing we can do ATM is either debug through or sit and wait.

OOPS!

Mese
  • 807
  • 1
  • 12
  • 26
  • 2
    you probably have a typo there - you are uninstalling twice – Zoidy Feb 08 '18 at 12:01
  • 2
    This didn't work for me, have I missed a trick or that is the case for everyone? – Sadiq Ali Feb 08 '18 at 12:09
  • It doesn't work, see the edit (that's why I cancelled your Edit, I already had editted it before you submitted your edit, but thanks!) – Mese Feb 08 '18 at 12:11
0

Edit

Just execute yarn upgrade.

There was a release of copy_webpack_plugin fixing the bug (4.4.1), so this should be preferred for resolving this issue. With npm, npm --depth 9999 update should do the trick to update all dependencies recursively.

Regarding the depth argument for npm update:

As of npm@2.6.1, the npm update will only inspect top-level packages. Prior versions of npm would also recursively inspect all dependencies. To get the old behavior, use npm --depth 9999 update

Original answer below:

Solution

rm -rf node_modules package-lock.json
npm i copy-webpack-plugin@4.3.1 -E -O
npm i

Explanation:

  • We remove node_modules and lockfile
  • We specify copy_webpack_plugin only as a peer dependency (option -O) and with an exact version (option -E)
  • We install node_modules
Community
  • 1
  • 1
Michel
  • 26,600
  • 6
  • 64
  • 69
0

if npm install copy-webpack-plugin@4.3.1 doesn`t help try add in package.json:

"optionalDependencies": { "copy-webpack-plugin": "4.3.1" }, "resolutions": { "copy-webpack-plugin": "4.3.1" }

0

Try this command -> npm install copy-webpack-plugin@4.3.0 resolved my issue

chhaya Joshi
  • 47
  • 1
  • 12
-2

run this command npm install copy-webpack-plugin@4.3.0

lohita
  • 31
  • 3
-2

callbacks[i](err, result); ^

TypeError: callbacks[i] is not a function

solution:- npm install copy-webpack-plugin@4.3.0

vali rala
  • 1
  • 2
-4

Try to uninstall and reinstall Angular CLI :

Global package:

npm uninstall -g @angular/cli npm cache clean if npm version is > 5 then usenpm cache verifyto avoid errors (or to avoid using --force) npm install -g @angular/cli@latest

Local project package:

rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell npm install --save-dev @angular/cli@latest npm install

Emile Cantero
  • 1,943
  • 3
  • 22
  • 47