Skip to content

No module factory available for dependency type: ContextElementDependency (after update 1.6.8 -> 1.7.0) #9680

Closed

Description

@AndreyYevtukhov

Having a build error after update to 1.7.0

No module factory available for dependency type: ContextElementDependency

Versions

ng -v

Angular CLI: 1.7.0
Node: 8.9.1
OS: win32 x64
Angular: 5.2.5
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@ angular/cli: 1.7.0
@ angular-devkit/build-optimizer: 0.3.1
@ angular-devkit/core: 0.3.1
@ angular-devkit/schematics: 0.3.1
@ ngtools/json-schema: 1.2.0
@ ngtools/webpack: 1.10.0
@ schematics/angular: 0.3.1
@ schematics/package-update: 0.3.1
typescript: 2.4.2
webpack-dev-server: 2.9.7
webpack: 3.10.0


P.s.

  1. removing node_modules and reinstalling with npm i - didn't help
  2. trying to npm i @angular/cli --save-dev - didn't help
  3. downgrade to 1.6.8 - helped

Activity

  1. AndreyYevtukhov commented on Feb 19, 2018

    @AndreyYevtukhov
    Author

    Error in npm's debug.log

    13 verbose stack Error: serviceName@0.0.0 bd: ng build --watch --deploy-url=src/
    13 verbose stack Exit status 1
    13 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:280:16)
    13 verbose stack at emitTwo (events.js:126:13)
    13 verbose stack at EventEmitter.emit (events.js:214:7)
    13 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
    13 verbose stack at emitTwo (events.js:126:13)
    13 verbose stack at ChildProcess.emit (events.js:214:7)
    13 verbose stack at maybeClose (internal/child_process.js:925:16)
    13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

  2. Patrick-Kan commented on Feb 19, 2018

    @Patrick-Kan

    same here. ng serve then ctrl - c then run ng-serve throw error port 4200 is in use.

  3. lnu commented on Feb 20, 2018

    @lnu

    Same issue here after migrating from 1.6.6 to 1.7.0:

     23% building modules 110/122 modules 12 active ...\kendo-angular-upload\dist\es\main.js
    An error occured during the build:
    Error: No module factory available for dependency type: ContextElementDependency
    
  4. RomainMarecat commented on Feb 20, 2018

    @RomainMarecat

    I had the same issue with LazyLoading routing feature difference and angular-cli 1.6.8 -> 1.7.0

    Angular CLI: 1.7.0
    Node: 7.10.1
    OS: darwin x64
    Angular: 5.1.0
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, router
    
    @angular/cdk: 5.0.0
    @angular/cli: 1.7.0
    @angular/material: 5.0.0
    @angular-devkit/build-optimizer: 0.3.1
    @angular-devkit/core: 0.3.1
    @angular-devkit/schematics: 0.3.1
    @ngtools/json-schema: 1.2.0
    @ngtools/webpack: 1.10.0
    @schematics/angular: 0.3.1
    @schematics/package-update: 0.3.1
    typescript: 2.5.3
    webpack: 3.11.0
    
  5. amcdnl commented on Feb 20, 2018

    @amcdnl

    Same issue here. Made no changes and upgraded and got the same error.

     67% building modules 666/694 modules 28 active . No module factory available for dependency type: ContextElementDependency
    

    Versions:

            "@angular/cli": "^1.7.0",
            "@angular/compiler-cli": "^5.2.5",
            "@angular/language-service": "^5.2.5",
            "@angular/animations": "^5.2.5",
            "@angular/common": "^5.2.5",
            "@angular/compiler": "^5.2.5",
            "@angular/core": "^5.2.5",
            "@angular/forms": "^5.2.5",
            "@angular/http": "^5.2.5",
            "@angular/platform-browser": "^5.2.5",
            "@angular/platform-browser-dynamic": "^5.2.5",
            "@angular/router": "^5.2.5",
            "rxjs": "^5.5.6",
            "zone.js": "^0.8.20"
            "ts-node": "^4.1.0",
            "tslint": "^5.9.0",
            "typescript": "^2.6.2",
    
  6. amcdnl commented on Feb 22, 2018

    @amcdnl

    Tested on 1.7.1 and still happening :(

  7. filipesilva commented on Feb 22, 2018

    @filipesilva
    Contributor

    Heya, this issue is a duplicate of #6417. You can see the answer to it in #6417 (comment).

    The short version is that you can't have multiple versions of webpack on your node_modules. Removing the extra webpack installs should fix it.

  8. amcdnl commented on Feb 22, 2018

    @amcdnl

    This was happening for me because I had storybook installed which comes with its own webpack version.

  9. GeorgeKnap commented on Apr 3, 2018

    @GeorgeKnap

    @filipesilva
    Hi, I've seen your explanation over and over but I haven't been able to build app without explicitly installing webpack in my devDependencies since cli version 1.6 or so.
    Without webpack I've been getting this error Cannot find module 'webpack/lib/node/NodeTemplatePlugin'.
    That was always fixed by having webpack in devDependencies.

    Now after upgrading to RC 6 versions I'm getting exactly same ContextElementDependency error and removing webpack from devDependencies simply causes the NodeTemplatePlugin error again.

    I wonder what's wrong here.

    @angular 6.0.0-rc.1
    @angular/cli v6.0.0-rc.0
    webpack 4.4.1
    
    
    
  10. davyvanlaere commented on Jun 4, 2018

    @davyvanlaere

    I have the exact same issue with the NodeTemplatePlugin error. The only way to fix is is by installing a higher webpack version ...

  11. AlaaAhmedBM commented on Aug 1, 2018

    @AlaaAhmedBM

    Do anyone get a solution to this error?

  12. yzini-eagle commented on Aug 2, 2018

    @yzini-eagle

    @AlaaAhmedBM try this answer just remove the package-lock.json before npm install it worked for me!

  13. redplane commented on Aug 4, 2018

    @redplane

    I have the same issue.
    I've search for solutions and uninstall webpack from my project.
    When I run the command : ng serve, I have another one: Cannot find module webpack.

    Its very annoying.

  14. redplane commented on Aug 4, 2018

    @redplane

    @yzini-eagle , seeing your solution. What I have tried is :

    • Remove node_modules.
    • Remove package-lock.json.
    • npm cache clean --force
    • npm install

    It worked. However, I don't know what the root cause is.

  15. adujoseph commented on Aug 15, 2018

    @adujoseph

    This works just fine for me with angular 6:
    remove webpack from DevDependencies in Package.json
    rimraf node_modules/ (remove node_modules folder)
    rimraf package-lock.json (remove package-lock.json file)
    npm install -g webpack (install webpack globally)
    npm install -g webpack-dev-server
    npm install
    ng serve or ng build

  16. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  17. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions