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.

Cannot find module rox-node

See original GitHub issue

Bug report

Describe the bug

When using rox-ssr-multi-entrypoints with nextjs, it appears that webpack is not bundling a indirect dependency, rox-node

To Reproduce

I created a repo here using the following steps:

  1. npx create-next-app rox-node-issue
  2. yarn add rox-ssr-milti-entrypoints
  3. open pages/index.js and add the following code snippet to the bottom
Home.getInitialProps = () => ({foo: 'bar'})

import { Rox } from 'rox-ssr-multi-entrypoints'

Rox.register('', {})
Rox.setup('12345')
  1. Install vercel: yarn add -D now
  2. deploy with now or yarn now (if node_modules not in default path) and follow steps. (Could probably reproduce it locally with yarn build
  3. browse the deployed app on vercel and check the logs (see latest here)

Expected behavior

The module rox-node is a dependency of rox-ssr so it should be part of the bundle, but on the server during SSR it appears not to be available.

Screenshots

image image

System information

  • hosted on vercel
  • Version of Next.js: 9.4.4
  • Version of Node.js: 12.5.0

Additional context

The issue is also logged here at rox-ssr-multi-entrypoints repo.

The issue ONLY happens when getInitialProps is used (even on pages that do not strictly make use of rox/rollout).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
timneutkenscommented, Jun 9, 2020

babel supports it

What does Babel support? Babel parses code, turn it into an AST and then runs plugins to transform the AST. Babel is not a bundler and as such does not support bundling.

There are many packages that use eval()

This in particular is a package that uses eval("require('something')") as @styfle explained. This generally means that the original author tried to hack around bundlers and intended for the library to not work in many use-cases including bundling server-side code. It should definitely be fixed by them as they did not use the browser field to solve this issue. Which gives significantly better results including correct tree shaking which it currently does not do.

1reaction
cyrus-zacommented, Jun 4, 2020

Thanks @styfle I responded to the package author. The package is open source here but you are correct that the dependencies do not seem to have a public git repository, only a npm package.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I resolve "Cannot find module" error using Node.js?
This error can be encountered if you are require ing a module that has a missing or incorrect main ...
Read more >
cannot find module [Node npm Error Solved] - freeCodeCamp
How to Fix the "cannot find module" Error · delete the node modules folder by running rm -rf node_modules · delete package.lock.json file...
Read more >
Cannot find module 'X' error in Node.js | bobbyhadz
To solve the "Cannot find module" error in Node.js, make sure to install the package from the error message if it's a third-party...
Read more >
How to resolve "Cannot find module" error in Node - Sabe.io
The issue is that Node is unable to find the module that you are trying to import into your Node application. The most...
Read more >
How to resolve can't find module error in Node.js - Reactgo
To fix Cannot find module errors, install the modules properly by running a npm install command in the appropriate directory as your project's ......
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