Building for production… ERROR TypeError: Cannot read property ‘createHash‘ of undefined

NPM run build package error reporting

Problem description
1. Because I recently updated my global webpack version, some old projects report errors in install;

2. For an old project, the webpack version is not specified in devdependences in package.json, which causes the project to fail during NPM install. Solve the problem by specifying the webpack version as ^ 4.0.0;

3. Later, when the project was modified and packaged, an error was reported:

Building for production… Error typeerror: cannot read property ‘createhash’ of undefined

final solution
NPM install webpack @ ^ 4.5.0 – d


yarn add [email protected]^4.5.0 -D

The problem can be solved by updating the version of webpack to version 4.5.0. I tried it again and again from @ ^ 4.0.0, @ ^ 4.1.0, @ ^ 4.2.0 and @ ^ 4.5.0. Really

Summarize the lessons of
blood and tears. Although I didn’t start this project, I tasted its pit, so remember to add the local webpack version number to package.json when starting a project in the future. Remember ~ ~ ~

Similar Posts: