Skip to content

Bug with angular-cli #57

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
TolotraRam opened this issue Jul 5, 2017 · 12 comments
Closed

Bug with angular-cli #57

TolotraRam opened this issue Jul 5, 2017 · 12 comments
Assignees
Milestone

Comments

@TolotraRam
Copy link

Hi,

Here is the step to reproduce the bug :

  • Generate new project (ng new project_name)
  • npm i
  • ng serve (Work fine)
  • npm install angular2gridster --save
  • ng serve (Work fine)
  • remove node_modules folder (Simulate a new clone on some project)
  • npm i (with angular2gridster already in dependencies)
  • ng serve (Fail)

Output :
Error: No module factory available for dependency type: ContextElementDependency
at Compilation.addModuleDependencies.

Cheers,

@TolotraRam
Copy link
Author

It's only with lazy loading routes

@swiety85
Copy link
Owner

swiety85 commented Jul 5, 2017

Hi, it seams that it could be more general issue: angular/angular-cli#4246, nevertheless I will have a look on that.
Thanx for info.

@TolotraRam
Copy link
Author

Re,
Yes there is a bug with angular-cli but something strange is that if i uninstall angular2gridster ng serve didn't fail (Work as expected) but if i install angular2gridster it cause the bug.

@TolotraRam
Copy link
Author

Ok here are some test i did such as i didn't install angular2gridster with npm but integrate the source with my project like your demo page and things work fine. Thinks it's something weird about the webpack version you included in your package as dependencies.

@swiety85
Copy link
Owner

swiety85 commented Jul 6, 2017

Can you send me which version of angular cli you use?

@TolotraRam
Copy link
Author

I've used 1.0.4 before and now used 1.2.0

@HyenaCros
Copy link

I had the same problem and I'm sure it has something to do with webpack versions. I managed to solve the problem by installing the angular cli locally before running normal npm install. I noticed that if I installed normally, angular cli would have webpack in its node_modules folder but not if I installed the it first.

@Halynsky
Copy link

Halynsky commented Jul 8, 2017

I have similar problem. We also have many LazyLoading modules in our project.

Angular - 4.2.5
AngularCLI - 1.2.0
Webpack - 3.1.0

[ERROR]  12% building modules 21/28 modules 7 active ...de_modules\css-loader\lib\cs
 13% building modules 29/43 modules 14 active ...src\app\components\app.component.html
[ERROR] An error occured during the build:
[ERROR] Error: No module factory available for dependency type: ContextElementDependency
[ERROR]     at Compilation.addModuleDependencies (E:\WorkSpase\improver\browser\node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:206:21)
[ERROR]     at Compilation.processModuleDependencies (E:\WorkSpase\improver\browser\node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:195:8)
[ERROR]     at _this.buildModule.err (E:\WorkSpase\improver\browser\node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:336:13)
[ERROR]     at building.forEach.cb (E:\WorkSpase\improver\browser\node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:140:27)
[ERROR]     at Array.forEach (native)
[ERROR]     at callback (E:\WorkSpase\improver\browser\node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:140:13)
[ERROR]     at module.build (E:\WorkSpase\improver\browser\node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:167:11)
[ERROR]     at resolveDependencies (E:\WorkSpase\improver\browser\node_modules\@angular\cli\node_modules\webpack\lib\ContextModule.js:133:4)
[ERROR]     at ContextModule.result.resolveDependencies (E:\WorkSpase\improver\browser\node_modules\@ngtools\webpack\src\plugin.js:229:25)
[ERROR]     at ContextModule.build (E:\WorkSpase\improver\browser\node_modules\@angular\cli\node_modules\webpack\lib\ContextModule.js:103:8)
[ERROR]     at Compilation.buildModule (E:\WorkSpase\improver\browser\node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:142:10)
[ERROR]     at factoryCallback (E:\WorkSpase\improver\browser\node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:325:11)
[ERROR]     at E:\WorkSpase\improver\browser\node_modules\@angular\cli\node_modules\webpack\lib\ContextModuleFactory.js:96:12
[ERROR]     at E:\WorkSpase\improver\browser\node_modules\tapable\lib\Tapable.js:204:11
[ERROR]     at done.then (E:\WorkSpase\improver\browser\node_modules\@ngtools\webpack\src\plugin.js:231:28)
[ERROR]     at <anonymous>

@swiety85 swiety85 self-assigned this Jul 12, 2017
@swiety85 swiety85 added this to the Version 0.7 milestone Jul 12, 2017
@rudzikdawid
Copy link
Collaborator

same issue here

npm ls -g --depth=0

/usr/lib
├── [email protected]
└── [email protected]

package.json:

  "dependencies": {
    "@angular/animations": "^4.3.0",
    "@angular/cdk": "github:angular/cdk-builds",
    "@angular/common": "^4.3.0",
    "@angular/compiler": "^4.3.0",
    "@angular/core": "^4.3.0",
    "@angular/flex-layout": "angular/flex-layout-builds",
    "@angular/forms": "^4.3.0",
    "@angular/http": "^4.3.0",
    "@angular/material": "angular/material2-builds",
    "@angular/platform-browser": "^4.3.0",
    "@angular/platform-browser-dynamic": "^4.3.0",
    "@angular/platform-server": "^4.3.0",
    "@angular/router": "^4.3.0",
    "angular2gridster": "^0.6.3",
    "core-js": "^2.4.1",
    "hammerjs": "^2.0.8",
    "rxjs": "^5.0.1",
    "zone.js": "^0.8.12"
  },
  "devDependencies": {
    "@angular/cli": "^1.2.3",
    "@angular/compiler-cli": "^4.3.0",
    "@types/jasmine": "2.5.46",
    "@types/node": "~7.0.12",
    "codelyzer": "~3.0.1",
    "simple-git": "^1.69.0",
    "simple-terminal-menu": "^1.1.3",
    "ts-node": "~3.0.4",
    "tslint": "^5.3.2",
    "typescript": "^2.4.1"
  }

ng serve

12% building modules 17/29 modules 12 active ...art/node_modules/zone.js/dist/zone.jsError: No module factory available for dependency type: ContextElementDependency
    at Compilation.addModuleDependencies (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/Compilation.js:206:21)
    at Compilation.processModuleDependencies (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/Compilation.js:195:8)
    at _this.buildModule.err (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/Compilation.js:336:13)
    at building.forEach.cb (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/Compilation.js:140:27)
    at Array.forEach (native)
    at callback (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/Compilation.js:140:13)
    at module.build (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/Compilation.js:167:11)
    at resolveDependencies (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/ContextModule.js:133:4)
    at ContextModule.result.resolveDependencies (/home/mike_oldfield/material2-start/node_modules/@ngtools/webpack/src/plugin.js:249:25)
    at ContextModule.build (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/ContextModule.js:103:8)
    at Compilation.buildModule (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/Compilation.js:142:10)
    at factoryCallback (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/Compilation.js:325:11)
    at /home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/ContextModuleFactory.js:96:12
    at /home/mike_oldfield/material2-start/node_modules/tapable/lib/Tapable.js:250:11
    at done.then (/home/mike_oldfield/material2-start/node_modules/@ngtools/webpack/src/plugin.js:251:28)               13% building modules 29/36 modules 7 active ...terial2-start/node_modules/rxjs/Rx.js/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/Compilation.js:265
                                if(_this.profile) {
                                        ^

TypeError: Cannot read property 'profile' of null
    at factoryCallback (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/Compilation.js:265:13)
    at factory (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/NormalModuleFactory.js:253:5)
    at applyPluginsAsyncWaterfall (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/NormalModuleFactory.js:99:14)
    at /home/mike_oldfield/material2-start/node_modules/tapable/lib/Tapable.js:250:11
    at NormalModuleFactory.params.normalModuleFactory.plugin (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/CompatibilityPlugin.js:52:5)
    at NormalModuleFactory.applyPluginsAsyncWaterfall (/home/mike_oldfield/material2-start/node_modules/tapable/lib/Tapable.js:254:13)
    at resolver (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/NormalModuleFactory.js:74:11)
    at process.nextTick (/home/mike_oldfield/material2-start/node_modules/@angular/cli/node_modules/webpack/lib/NormalModuleFactory.js:205:8)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)

@rudzikdawid
Copy link
Collaborator

It could be afected by package.json dependency: "webpack": "^2.2.1"
Maybe webpack should by in devDependencies section ?

swiety85 pushed a commit that referenced this issue Jul 28, 2017
Try to fix bug with angular-cli #57
@swiety85
Copy link
Owner

You were right. It seamed to be webpack dependency issue. It should be fixed in v.0.6.4.
Please check and give a hint if it works.

@rudzikdawid
Copy link
Collaborator

It seems like everything work just fine.
aot compilation without errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants