Angular CLI gives me “TypeError: callbacks[i] is n

2019-01-07 09:34发布

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.

12条回答
男人必须洒脱
2楼-- · 2019-01-07 09:49

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" }

查看更多
贼婆χ
3楼-- · 2019-01-07 09:50

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

查看更多
聊天终结者
4楼-- · 2019-01-07 09:55

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

查看更多
Melony?
5楼-- · 2019-01-07 10:03

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.

查看更多
做自己的国王
6楼-- · 2019-01-07 10:04

callbacks[i](err, result); ^

TypeError: callbacks[i] is not a function

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

查看更多
Root(大扎)
7楼-- · 2019-01-07 10:05

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

查看更多
登录 后发表回答