Angular CLI gives me “TypeError: callbacks[i] is not a function” when I “ng serve”

前端 未结 12 1336
旧时难觅i
旧时难觅i 2020-12-08 02:26

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:

相关标签:
12条回答
  • 2020-12-08 02:43

    I had same problem and this command did miracle for me

    npm install copy-webpack-plugin@4.3.1
    
    0 讨论(0)
  • 2020-12-08 02:43

    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

    0 讨论(0)
  • 2020-12-08 02:47

    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.

    0 讨论(0)
  • 2020-12-08 02:52

    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
    0 讨论(0)
  • 2020-12-08 02:53

    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!

    0 讨论(0)
  • 2020-12-08 02:54

    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

    0 讨论(0)
提交回复
热议问题