Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AndreyYevtukhov opened this issue Feb 19, 2018 · 16 comments

Comments

@AndreyYevtukhov
Copy link

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
@AndreyYevtukhov
Copy link
Author

Error in npm's debug.log

13 verbose stack Error: [email protected] 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)

@Patrick-Kan
Copy link

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

@lnu
Copy link

lnu commented Feb 20, 2018

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

@RomainMarecat
Copy link

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

@amcdnl
Copy link

amcdnl commented Feb 20, 2018

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

@amcdnl
Copy link

amcdnl commented Feb 22, 2018

Tested on 1.7.1 and still happening :(

@filipesilva
Copy link
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.

@amcdnl
Copy link

amcdnl commented Feb 22, 2018

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

@GeorgeKnap
Copy link

@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


@davyvanlaere
Copy link

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

@AlaaAhmedBM
Copy link

AlaaAhmedBM commented Aug 1, 2018

Do anyone get a solution to this error?

@yzini-eagle
Copy link

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

@redplane
Copy link

redplane commented Aug 4, 2018

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.

@redplane
Copy link

redplane commented Aug 4, 2018

@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.

@adujoseph
Copy link

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

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests