Cannot find module rox-node
See original GitHub issueBug 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:
npx create-next-app rox-node-issue
yarn add rox-ssr-milti-entrypoints
- 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')
- Install vercel:
yarn add -D now
- deploy with
now
oryarn now
(if node_modules not in default path) and follow steps. (Could probably reproduce it locally withyarn build
- 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
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:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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 thebrowser
field to solve this issue. Which gives significantly better results including correct tree shaking which it currently does not do.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.