create-react-app: Cannot read property 'thisCompilation' of undefined during npm run build
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:
- Operating system: Debian 9.3 (Docker nginx:1.13)
- 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 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
…
Reproducible Demo
TBD - will try to create a docker with mock project.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 18 (7 by maintainers)
I’m going to close because there were no reproducible examples shared.
To solve this problem:
node_modules
package-lock.json
if presentreact-scripts
inpackage.json
, make sure you don’t havewebpack
in ityarn
(ornpm install
)package.json
ornode_modules
in the parent folders of your projectTLDR: 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.
As gaearon said, following steps worked for me:
Also ran into this.
I got this after using
npm install
. Installing usingyarn
removed this error for me.having this error with webpack 4 and storybook works with webpack 3
@NickFoden so you suggest using Yarn? What if I don’t want to use it?