I ran yarn upgrade, which clearly was a mistake, but in any case now I can’t seem to find any way back to get my project running again. Now, when I run yarn build I get the error: webpack: command not found.
I’ve made sure my version of package.json matched what it was previously when I had no issues.
This is what my package.json looks like at my theme root for webpack packages in my devDependencies:
Has anyone had this issue? What else do I need to check and possibly troubleshoot that yarn upgrade could’ve caused? Do I need to reinstall webpack or related packages? Since I believe these are added back at the time of installing the theme as dependencies, I’m not sure what else exactly to go off here other than what I had previously in my package.json before things went off track.
After re-installing webpack and related dependencies to resolve the not found error, I’m now getting errors that those same packages can’t be found in various files in resources > assets > build, namely webpack.config.js and config.js when running yarn build:
@alwaysblank Thanks for the quick reply. I was able to reset to a recent commit using a previously working yarn.lock file. I did follow your instructions to remove node_modules and then run yarn, but I then got the very same error: webpack: command not found
Do you think it’s worth reinstalling all dependencies or is there not some issue with webpack specifically? I’ve already tried reinstalling many of the webpack related packages. It’s odd. When I reinstall webpack it says “Saved 0 new dependencies” but then if I run yarn build after I will get a different error than before.
@alwaysblank Tried both your first and second list of instructions and keep getting the same error. I completely removed yarn.lock and package.json and reinstalled all dependencies. Same exact sequence of events where I successfully install webpack but then later get the error that webpack isn’t installed. Then, if I reinstall webpack I get an error that webpack-merge or some other package can’t be found. Then if I install that package, I’m back to the webpack not found error. Seem to be going in circles.
In my theme root I needed add webpack-cli: yarn add webpack-cli --dev
This solved the issue. Stumbled upon the answer here as suggested in the second to last comment there, and it worked. Oddly, webpack-cli wasn’t ever in package.json in any of my previous commits, but it appears that’s what I needed, and my site is back and appears to be working as normal.