-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Cannot read property 'thisCompilation' of undefined during npm run build #4076
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
Comments
I got this after using |
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: 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. |
having this error with webpack 4 and storybook @NickFoden so you suggest using Yarn? What if I don't want to use it? |
Please file this bug with npm, it sounds like a bug in their package resolution algorithm. You can use Yarn in the meantime. |
@Timer I use yarn and still got this error |
Can someone please provide a small reproducible demo? |
Also ran into this. |
Installing using yarn removed this error for me too. |
Just stay on the 3.0.2 version of the plugin for being compatible with webpack 3.x. |
I'm going to close because there were no reproducible examples shared. To solve this problem:
|
I also got this error and install using yarn instead of npm worked |
If you're like me and have a build task using webpack v4 inside a CRA, turns out npm doesn't know how to let react-scripts depend on its own webpack version. As @davejm said, yarn works correctly. |
As gaearon said, following steps worked for me:
|
Just uninstall webpack with |
Create React App users never need to install webpack unless they’ve ejected. I want to make it clear to future readers. |
I ran into this similar issue, mainly because in a bad move, I had (not realizing I didn't need to install it) installed webpack to a higher version that what Create React App was expecting. Then, I uninstalled it, and ran into a different issue of missing webpack. Finally resolved it by installing the version of webpack suggested above, 3.11.0 |
If you use Create React App you don't need to install webpack at all, and you're just going to keep hitting issues if you do. I don't know how else to put this. I keep writing about this in every comment, and people still ignore it. 😞 As I explained above you need to completely remove webpack from your Let's try again for future readers: You cannot have both
|
I'm locking because new comments just add confusion for future readers who are going to try wrong workarounds. If you experience this, and the suggestions in #4076 (comment) don't help, please file a new issue. Note that the instructions #4076 (comment) only apply to users who have |
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?
Yes
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
Environment
node -v
: 6.11.1npm -v
: 3.10.10yarn --version
(if you use Yarn): N/Anpm ls react-scripts
(if you haven’t ejected):Then, specify:
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 https://deb.nodesource.com/setup_6.x | bash -
apt-get -y install nodejs
curl https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash -
source ~/.nvm/nvm.sh
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
...
npm-debug.log
Reproducible Demo
TBD - will try to create a docker with mock project.
The text was updated successfully, but these errors were encountered: