“离子服务”给出错误“错误:没有模块工厂可用于依赖类型:ContextElementDependency”

时间:2019-11-12 15:19:05

标签: ionic-framework

我一直在尝试

  

离子服务-地址127.0.0.1

由于以下错误,整天没有运气。长期以来一直在研究和调查此问题,因此这里存在这个问题。

$ ionic serve
$ ng.cmd run app:serve --host=localhost --port=8100
[INFO] Waiting for connectivity with ng...
[INFO] Waiting for connectivity with ng...
[INFO] Waiting for connectivity with ng...
[INFO] Waiting for connectivity with ng...
[INFO] Waiting for connectivity with ng...
[INFO] Waiting for connectivity with ng...
[INFO] Waiting for connectivity with ng...
[INFO] Waiting for connectivity with ng...<br>
[INFO] Development server running!<br>
       Local: http://localhost:8100
       Use Ctrl+C to quit this process<br>
[INFO] Browser window opened to http://localhost:8100!<br>
[ng] i 「wdm」: wait until bundle finished: /
[ng] × 「wdm」: Error: No module factory available for dependency type: ContextElementDependency
[ng]     at addDependency (c:\Users\*******\Desktop\dev\app-name\node_modules\webpack\lib\Compilation.js:398:12)
[ng]     at iterationOfArrayCallback (c:\Users\*******\Desktop\dev\app-name\node_modules\webpack\lib\Compilation.js:80:3)
[ng]     at addDependenciesBlock (c:\Users\*******\Desktop\dev\app-name\node_modules\webpack\lib\Compilation.js:414:5)
[ng]     at iterationOfArrayCallback (c:\Users\*******\Desktop\dev\app-name\node_modules\webpack\lib\Compilation.js:80:3)
[ng]     at addDependenciesBlock (c:\Users\*******\Desktop\dev\app-name\node_modules\webpack\lib\Compilation.js:417:5)
[ng]     at Compilation.processModuleDependencies (c:\Users\*******\Desktop\dev\app-name\node_modules\webpack\lib\Compilation.js:425:4)
[ng]     at afterBuild (c:\Users\*******\Desktop\dev\app-name\node_modules\webpack\lib\Compilation.js:552:16)
[ng]     at _this.buildModule.err (c:\Users\*******\Desktop\dev\app-name\node_modules\webpack\lib\Compilation.js:598:11)
[ng]     at callback (c:\Users\*******\Desktop\dev\app-name\node_modules\webpack\lib\Compilation.js:349:35)
[ng]     at module.build.error (c:\Users\*******\Desktop\dev\app-name\node_modules\webpack\lib\Compilation.js:385:12)
[ng]     at resolveDependencies (c:\Users\*******\Desktop\dev\app-name\node_modules\webpack\lib\ContextModule.js:219:4)
[ng]     at ContextModule.result.resolveDependencies (c:\Users\*******\Desktop\dev\app-name\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:517:25)
[ng]     at ContextModule.build (c:\Users\*******\Desktop\dev\app-name\node_modules\webpack\lib\ContextModule.js:148:8)
[ng]     at Compilation.buildModule (c:\Users\*******\Desktop\dev\app-name\node_modules\webpack\lib\Compilation.js:353:10)
[ng]     at factory.create (c:\Users\*******\Desktop\dev\app-name\node_modules\webpack\lib\Compilation.js:579:15)
[ng]     at hooks.afterResolve.callAsync (c:\Users\*******\Desktop\dev\app-name\node_modules\webpack\lib\ContextModuleFactory.js:150:16)
[ng] c:\Users\*******\Desktop\dev\app-name\node_modules\neo-async\async.js:16
[ng]     throw new Error('Callback was already called.');
[ng]     ^
[ng] Error: Callback was already called.
[ng]     at throwError (c:\Users\*******\Desktop\dev\app-name\node_modules\neo-async\async.js:16:11)
[ng]     at c:\Users\*******\Desktop\dev\app-name\node_modules\neo-async\async.js:2818:7
[ng]     at process._tickCallback (internal/process/next_tick.js:61:11)<br><br>
[ERROR] ng has unexpectedly closed (exit code 1).<br><br>
        The Ionic CLI will exit. Please check any output above for error details.

其他详细信息

  

'ionic info'打印以下内容

Ionic:
   Ionic CLI            : 5.4.5 (C:\Users\******\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.11.4
   @angular-devkit/build-angular : 0.12.4
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1
Cordova:
   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : not available
   Cordova Plugins   : not available
Utility:
   cordova-res : not installed
   native-run  : not installed
System:
   NodeJS : v10.15.1 (C:\Program Files\nodejs\node.exe)
   npm    : 6.13.0
   OS     : Windows 10

希望我分享了足够的信息。任何帮助表示赞赏。谢谢

1 个答案:

答案 0 :(得分:1)

尝试为提到的错误模拟以下步骤。

  1. Package.json 文件中的DevDependencies中删除Webpack。

  2. rm -R node_modules(要删除 node_modules 文件夹)。

  3. npm i -g webpack

  4. npm i -g webpack-dev-server
  5. 删除 package-lock.json 文件(如果存在)。
  6. npm i(重新安装Node软件包)。
  7. npm start(或ionic serve)。