gatsby: Upgrading to v2 - Cannot find module 'webpack/lib/removeAndDo'

  • I followed the v1 to v2 doc

  • removed the node-modules folder and the package-lock.json file

  • ran npm cache verify then npm install and finally gatsby develop

  • and now getting the following error:

error UNHANDLED EXCEPTION


  Error: Cannot find module 'webpack/lib/removeAndDo'

  - v8-compile-cache.js:159 require
    [kaizen-2018]/[v8-compile-cache]/v8-compile-cache.js:159:20

  - ExtractedModule.js:30 Object.<anonymous>
    [kaizen-2018]/[extract-text-webpack-plugin]/ExtractedModule.js:30:42

  - v8-compile-cache.js:178 Module._compile
    [kaizen-2018]/[v8-compile-cache]/v8-compile-cache.js:178:30

  - v8-compile-cache.js:159 require
    [kaizen-2018]/[v8-compile-cache]/v8-compile-cache.js:159:20

  - index.js:7 Object.<anonymous>
    [kaizen-2018]/[extract-text-webpack-plugin]/index.js:7:23

  - v8-compile-cache.js:178 Module._compile
    [kaizen-2018]/[v8-compile-cache]/v8-compile-cache.js:178:30

  - v8-compile-cache.js:159 require
    [kaizen-2018]/[v8-compile-cache]/v8-compile-cache.js:159:20

  - index.js:3 Object.<anonymous>
    [kaizen-2018]/[gatsby-1-config-extract-plugin]/index.js:3:33

  - v8-compile-cache.js:178 Module._compile

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 6
  • Comments: 29 (12 by maintainers)

Most upvoted comments

Try bumping all your "gatsby-x" dependencies to version next, the same as gatsby and gatsby-image. Note that you’ll need to install extra dependencies for some plugins. See https://v2--gatsbyjs.netlify.com/docs/migrating-from-v1-to-v2/#manually-install-plugins-peer-dependencies

@DSchau,

I just updated from gatsby 2.19.32 to 2.20.21, and suddenly I wasn’t able to run gatsby develop. It would error out immediately with “cannot find module webpack”.

I updated all my gatsby-x packages, deleted package-lock and node_modules, then ran npm install, but I still kept getting the same error. Finally, I just went ahead and installed webpack (which I had never needed before) as a dev dependency, and voila, it worked.

My question is, why did I suddenly start needing webpack after just a minor update of Gatsby?

I’m still getting this error Cannot find module 'webpack/lib/removeAndDo' with gatsby-plugin-netlify-cms@next.

Before adding yarn add extract-text-webpack-plugin@^1.0.1 I got an error stating that Cannot find module 'extract-text-webpack-plugin'.

I tried removing yarn.lock and node_modules with no luck.

Looks like the netlify-cms plugin has an update for v2 but it doesn’t seem to work. Is it related this issue or should I create a new issue?

I believe Gatsby 2 has removed postcss plugins for now. So the plugin gatsby-plugin-postcss-sass is not compatible with Gatsby 2. Currently you can use https://next.gatsbyjs.org/docs/add-custom-webpack-config to define your webpack config to use postcss plugins. More info: https://github.com/gatsbyjs/gatsby/issues/5778#issuecomment-395711865

^ I upgraded from 1.9 (I know) to the latest version and had this problem until I installed webpack like @devuxer.

@anantoghosh Yeah, I just checked gatsby-plugin-postcss-sass page and saw an empty page 😃. Remove this plugin also fixed the issue.

Why are unsupported plugins not listed in the migration documentation? (or supported ones are listed here).

But I got another issue, I moved layout.js to the components folder, so I moved index.css too and now the site loses all styling 😃