23

I am upgrading to Angular 6, but it looks like i get an error when running ng serve or ng build.

I do get the following error

Cannot destructure property 'createHash' of 'undefined' or 'null'. TypeError: Cannot destructure property 'createHash' of 'undefined' or 'null'. at Object. (C:\Users\stian\Source\Repos\minside\src\MinSide.Web\Areas\ClientApp\node_modules\mini-css-extract-plugin\dist\index.js:26:44)

I have been following the update guide https://update.angular.io/

It looks like it is webpack related, but if anyone know how to fix this or has experienced it themselves. Help is appreciated

Fateme Fazli
  • 11,582
  • 2
  • 31
  • 48
stian64
  • 1,563
  • 3
  • 12
  • 25

3 Answers3

38

You need to update wepback from ^4.1.0 to ^4.3.0 or ^4.4.1

Melchia
  • 22,578
  • 22
  • 103
  • 117
Fateme Fazli
  • 11,582
  • 2
  • 31
  • 48
  • 1
    I have not installed webpack myself, so its not in my package.json. i do however see the npm package webpack version ~4.6.0 in node_modules/@angular-devkit/build-angular/webpack and @ngtools/webpack@6.0.1 in node_modules/@angular-devkit/build-angular/node_modules/@ngtools/webpack – stian64 May 15 '18 at 11:47
  • 7
    @stian64 try ```npm remove webpack``` then ```npm install webpack@4.4.1``` – Fateme Fazli May 15 '18 at 12:22
  • 1
    When i try that, i get this outputted: ERROR in ./src/main-accounting.ts Module build failed: Error: Angular Compiler was detected but it was an instance of the wrong class. This likely means you have several @ngtools/webpack packages installed. You can check this with `npm ls @ngtools/webpack`, and then remove the extra copies. Can i update the webpack ngtools have, or any other option? – stian64 May 15 '18 at 12:32
  • 4
    @stian64 would be good if remove node modules and package-lock.json and npm i again. – Fateme Fazli May 15 '18 at 12:50
  • 2
    Worked great! Easy fix – Vinorth Jul 02 '19 at 12:18
5

You need to Uninstall webpack

npm remove webpack

and Re-Install webpack

npm install webpack

Karar Barcha
  • 406
  • 4
  • 11
-1

Remove ! @ # or ... From your folders name and install your node again > npm install

  • Please include details of how this would resolve the issue. The original question does not seem to have special characters in their path – solbs Sep 07 '21 at 19:21