Next-pwa: Error: Cannot find module 'levenary'

Created on 9 Dec 2020  路  4Comments  路  Source: shadowwalker/next-pwa

Summary

The dependencies for workbox-build aren't being properly installed after upgrading from v3 to v5.

$ next build

> Build error occurred
Error: Cannot find module 'levenary'
Require stack:
- /src/node_modules/workbox-build/node_modules/@babel/helper-compilation-targets/lib/index.js
- /src/node_modules/workbox-build/node_modules/@babel/preset-env/lib/debug.js
- /src/node_modules/workbox-build/node_modules/@babel/preset-env/lib/index.js
- /src/node_modules/workbox-build/build/lib/bundle.js
- /src/node_modules/workbox-webpack-plugin/build/generate-sw.js
- /src/node_modules/workbox-webpack-plugin/build/index.js
- /src/node_modules/next-pwa/index.js
- /src/next.config.js
- /src/node_modules/next/dist/next-server/server/config.js
- /src/node_modules/next/dist/build/index.js
- /src/node_modules/next/dist/cli/next-build.js
- /src/node_modules/next/dist/bin/next
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:15)
    at Function.Module._load (node:internal/modules/cjs/loader:763:27)
    at Module.require (node:internal/modules/cjs/loader:991:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/src/node_modules/workbox-build/node_modules/@babel/helper-compilation-targets/lib/index.js:41:40)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32)
    at Function.Module._load (node:internal/modules/cjs/loader:807:14)
    at Module.require (node:internal/modules/cjs/loader:991:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/src/node_modules/workbox-build/node_modules/@babel/helper-compilation-targets/lib/index.js',
    '/src/node_modules/workbox-build/node_modules/@babel/preset-env/lib/debug.js',
    '/src/node_modules/workbox-build/node_modules/@babel/preset-env/lib/index.js',
    '/src/node_modules/workbox-build/build/lib/bundle.js',
    '/src/node_modules/workbox-webpack-plugin/build/generate-sw.js',
    '/src/node_modules/workbox-webpack-plugin/build/index.js',
    '/src/node_modules/next-pwa/index.js',
    '/src/next.config.js',
    '/src/node_modules/next/dist/next-server/server/config.js',
    '/src/node_modules/next/dist/build/index.js',
    '/src/node_modules/next/dist/cli/next-build.js',
    '/src/node_modules/next/dist/bin/next'
  ]
}

How To Reproduce

Steps to reproduce the behavior:

  1. Use next-pwa v5
  2. Run next build
  3. Error should interrupt the build
bug

Most helpful comment

Please try to delete .next, node_modules, and yarn.lock to try again. I tried on my next-9 example, it works fine for me.

All 4 comments

Got the same error after updating to v5.0.0. I deleted the .next folder and node_modules, ran yarn and next build again. Error persists. I'm using next v10.0.3.

Please try to delete .next, node_modules, and yarn.lock to try again. I tried on my next-9 example, it works fine for me.

Doing that caused yarn.lock to be regenerated with a bunch of changes which fixed the issue. I noticed in the diff that levenary is not present in any of the dependencies after updating the lockfile, but was present 5 times before.

I ran into the same problem after upgrading react-scripts from 4.0.1 to 4.0.2. After much helpless debugging we concluded that deleting the node_modules and running yarn install again solves the problem. No need to touch the yarn.lock file.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sugar3103 picture sugar3103  路  8Comments

vishwasnavadak picture vishwasnavadak  路  8Comments

paales picture paales  路  3Comments

yhay81 picture yhay81  路  5Comments

maximousblk picture maximousblk  路  7Comments