Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'thisCompilation' of undefined during npm run build

See original GitHub issue

I’ve been running react-scripts build in docker for last 3 months and suddenly our builds started failing this week (without any change in the package.json dependencies)

Is this a bug report?


Did you try recovering your dependencies?

Yes, using nvm with node 6.11.1 and npm 3.10.10

Which terms did you search for in User Guide?

using npm run build, not using anythin relevant


  1. node -v: 6.11.1
  2. npm -v: 3.10.10
  3. yarn --version (if you use Yarn): N/A
  4. npm ls react-scripts (if you haven’t ejected):

Then, specify:

  1. Operating system: Debian 9.3 (Docker nginx:1.13)
  2. Browser and version (if relevant): N/A

Steps to Reproduce

apt-get -y update apt-get -y install curl apt-get -y install gnupg apt-get -y install gnupg1 gnupg2 procps curl -sL | bash - apt-get -y install nodejs curl | bash - source ~/.nvm/ nvm list nvm install v6.11.1 npm install npm rebuild node-sass --force CI=“” npm run build

Expected Behavior

Creating an optimized production build… File sizes after gzip:

341.23 KB build/static/js/main.0a9ca280.js 35.24 KB build/static/css/main.7b053899.css …

Actual Behavior

Creating an optimized production build… Failed to compile.

Cannot read property ‘thisCompilation’ of undefined

npm ERR! Linux 4.9.60-linuxkit-aufs


Reproducible Demo

TBD - will try to create a docker with mock project.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

gaearoncommented, Jul 23, 2018

I’m going to close because there were no reproducible examples shared.

To solve this problem:

  • Delete node_modules
  • Delete package-lock.json if present
  • If you have react-scripts in package.json, make sure you don’t have webpack in it
  • Run yarn (or npm install)
  • Also make sure you don’t have package.json or node_modules in the parent folders of your project
NickFodencommented, Mar 2, 2018

TLDR: Error " Cannot read property ‘thisCompilation’ of undefined " in our React app (CRA initialization)- was additional install of dependency of webpack. Remove node_modules. Remove webpack in package.json. Yarn install. Good to go.

After npm run start was unable to compile. I had the error “Cannot read property ‘thisCompilation’ of undefined” within React app created with Create React App and error code ELIFECYCLE part of log here: error code ELIFECYCLE 21 error errno 1 22 error icon@0.1.0 start: react-scripts start 22 error Exit status 1 23 error Failed at the icon@0.1.0 start script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]

At first thought it was older semantic-ui running gulp-util but then we had “webpack” installed as a dependency in the package.json, which I believe after comparing to other repos built with CRA, is unnecessary dependency. 1. Removed node-modules and lockfiles and the “webpack” dependency. 2. Yarn install. 3. And npm run start no problem now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'thisCompilation' of undefined · Issue ...
Updating to 1.7.4 did not solve this for me, I still see get the Cannot read property 'thisCompilation' of undefined when running ng...
Read more >
Cannot read property 'thisCompilation' of undefined in Visual ...
This code is referring to a series of nodes and plugins that I had updated per a previous assignment that compiled without issue....
Read more >
Webpack error - Cannot read property 'thisCompilation' of ...
Webpack error - Cannot read property 'thisCompilation' of undefined. I am using copy-webpack-plugin to copy my entire images folder from src to dist...
Read more >
copy-webpack-plugin 出现Cannot read property ... - CSDN博客
Cannot read property compilation of undefined vue 打包运行npm run build 报错 ... Cannot read property thisCompilation of undefined 错误.
Read more >
当使用npm run build的时候报错:TypeError - 51CTO博客
当使用npm run build的时候报错:TypeError: Cannot read property 'thisCompilation' of undefined,最近接手公司前端外包出去的的项目, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found