question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module not found after pruning devDependencies

See original GitHub issue

Hi,

I get the following error message in production using next-seo@latest after stripping the project of devDependencies:

Require stack:
- /node_modules/next-seo/lib/index.js
- /.next/server/static/3sVp8qbx995daYZPgBBaY/pages/_app.js
- /node_modules/next/dist/next-server/server/load-components.js
- /node_modules/next/dist/next-server/server/api-utils.js
- /node_modules/next/dist/next-server/server/next-server.js
- /node_modules/next/dist/server/next.js
- /dist/server/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
    at Function.Module._load (internal/modules/cjs/loader.js:864:27)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/node_modules/next-seo/lib/index.js:1:42)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Module.require (internal/modules/cjs/loader.js:1044:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/node_modules/next-seo/lib/index.js',
'/.next/server/static/3sVp8qbx995daYZPgBBaY/pages/_app.js',
    '/node_modules/next/dist/next-server/server/load-components.js',
    '/node_modules/next/dist/next-server/server/api-utils.js',
    '/node_modules/next/dist/next-server/server/next-server.js',
    '/node_modules/next/dist/server/next.js',
    '/dist/server/index.js'
  ]
}
(node:25484) UnhandledPromiseRejectionWarning: Error: Cannot find module '@babel/runtime/helpers/interopRequireWildcard'
Require stack:
- /node_modules/next-seo/lib/index.js
- /.next/server/static/3sVp8qbx995daYZPgBBaY/pages/_app.js
- /node_modules/next/dist/next-server/server/load-components.js
- /node_modules/next/dist/next-server/server/api-utils.js
- /node_modules/next/dist/next-server/server/next-server.js
- /node_modules/next/dist/server/next.js
- /dist/server/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
    at Function.Module._load (internal/modules/cjs/loader.js:864:27)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/node_modules/next-seo/lib/index.js:1:42)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
(node:25484) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:25484) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Steps to reproduce:

  • Build nextjs app
  • Run my app locally and connect, everything seems to be fine
  • Run either npm prune --production or yarn install --production
  • Run app locally again, errors out on server side rendering with the above trace

I noticed that up to 4.1.0 everything works as expected, 4.2.0 seems to be introducing the issue.

Best regards, Oliver

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
vimotacommented, Mar 29, 2020

I still ran into this error Can't resolve '@babel/runtime-corejs2/core-js/array/is-array' in '/Users/vimota/code/vimota/node_modules/next-seo/lib/jsonld' with no custom babel configuration.

Running npm install --save-dev @babel/runtime-corejs2 resolved it, so perhaps it needs to be added as a dependency?

0reactions
RobbyUitbeijersecommented, Apr 17, 2020

Update: removed my original comment - we are not experiencing this issue anymore from next@9.3 anymore

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why doesn't `npm prune` remove folders from node_modules?
I want to remove folders which are NOT specified in my devDependencies. This is different from what you are suggesting. I want my...
Read more >
`npm prune --production` deletes dependencies found in both ...
The dependency is deleted from your node_modules folder. What I expect to happen: The dependency should not be deleted, as it is a...
Read more >
Uninstalling dev dependencies with npm by Josh Sherman
The npm prune command, without any arguments will clean up any packages that are installed and not listed in your dependency lists.
Read more >
npm-prune
Description. This command removes "extraneous" packages. If a package name is provided, then only packages matching one of the supplied names are removed....
Read more >
Troubleshooting Node.js Deploys - Heroku Dev Center
If a module that is included in the package.json is missing from the ... is in the devDependencies that is needed after the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found