Angular-cli: Can't resolve 'events' in 'node_modules\webpack\hot'

Created on 12 Nov 2018  路  10Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [ x ] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [x ] serve

Versions


Angular CLI: 7.0.5
Node: 9.8.0
OS: win32 x64
Angular: 7.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.10.5
@angular-devkit/build-angular 0.10.5
@angular-devkit/build-optimizer 0.10.5
@angular-devkit/build-webpack 0.10.5
@angular-devkit/core 7.0.5
@angular-devkit/schematics 7.0.5
@angular/cli 7.0.5
@ngtools/webpack 7.0.5
@schematics/angular 7.0.5
@schematics/update 0.10.5
rxjs 6.3.3
typescript 3.1.6
webpack 4.19.1

Repro steps

The log given by the failure


Can't resolve 'events' in 'node_modules\webpack\hot'

Desired functionality

When I update my project from Angular 6 to Angular 7, after running ng serve command, there was an error ' Can't resolve 'events' in 'node_modules\webpack\hot'' displayed in my console.

Mention any other details that might be useful

Here is my package.json:

{
  "name": "administration",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~7.0.3",
    "@angular/common": "~7.0.3",
    "@angular/compiler": "~7.0.3",
    "@angular/core": "~7.0.3",
    "@angular/forms": "~7.0.3",
    "@angular/http": "~7.0.3",
    "@angular/platform-browser": "~7.0.3",
    "@angular/platform-browser-dynamic": "~7.0.3",
    "@angular/router": "~7.0.3",
    "@ngx-translate/core": "^11.0.0",
    "@ngx-translate/http-loader": "^4.0.0",
    "bootstrap": "^4.1.3",
    "core-js": "^2.5.7",
    "font-awesome": "^4.7.0",
    "jquery-slimscroll": "^1.3.8",
    "moment": "^2.22.2",
    "ngx-bootstrap": "^3.1.1",
    "ngx-moment": "^3.2.0",
    "rxjs": "^6.3.3",
    "rxjs-compat": "^6.3.3",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.10.5",
    "@angular/cli": "~7.0.5",
    "@angular/compiler-cli": "~7.0.3",
    "@angular/language-service": "~7.0.3",
    "@types/jasmine": "^2.8.11",
    "@types/node": "^10.12.5",
    "codelyzer": "^4.5.0",
    "jasmine-core": "^3.3.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^3.1.1",
    "karma-chrome-launcher": "^2.2.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.1.2",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "^5.4.1",
    "rxjs-tslint": "^0.1.5",
    "ts-node": "^7.0.1",
    "tslint": "^5.11.0",
    "typescript": "^3.1.6"
  }
}

more info

Most helpful comment

Same issue after upgrading angular 6 to angular 7, the following steps fixed it for me:

  • remove local node_modules folder
  • remove package-lock.json
  • run npm install

All 10 comments

Hi, have you tried to delete and re-install the node_modules?

Yes, I have tried.
But it still happens.

Are you using a lock file? If so have you tried to delete it?

I'm sorry, but this issue is not caused by Angular CLI.

This issue tracker is not suitable for support requests, please repost your issue on StackOverflow using tag angular-cli.

If you are wondering why we don't resolve support issues via the issue tracker, please check out this explanation.

How did you solve it ?

How did you solve it ?

Well I had same issue and this did the trick for me :

https://github.com/darul75/web-react/issues/12#issuecomment-267388886

@jas75 , @imadhy just told my solution :)
btw, if you are using angular-cli, you should remove webpack from local node_modules also.

Same issue after upgrading angular 6 to angular 7, the following steps fixed it for me:

  • remove local node_modules folder
  • remove package-lock.json
  • run npm install

The underlying problem is actually on the webpack side. It uses the events package but does not list it as a dependency. This then prevents package managers from putting the package in a location that is guaranteed to be found by webpack. This can also completely break depending on the choice of package manager as package hoisting behavior is not standardized.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jmurphzyo picture jmurphzyo  路  3Comments

IngvarKofoed picture IngvarKofoed  路  3Comments

JanStureNielsen picture JanStureNielsen  路  3Comments

brtnshrdr picture brtnshrdr  路  3Comments

purushottamjha picture purushottamjha  路  3Comments