-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot find module 'tween' when requiring scroll-to server side #9
Comments
can someone take an action on this? thanks |
+1 Any help, @TooTallNate? |
You can bypass this issue using conditional require. instead of see: vercel/next.js#219 (comment) |
On the off chance that anyone using Gatsby finds their way here, putting this snippet into exports.modifyWebpackConfig = ({ config, stage }) => {
if (stage === 'build-html') {
config.loader('null', {
test: /scroll-to-element/,
loader: 'null-loader',
});
}
}; |
Thanks, @fritz-c this solved it for me but I had to change
|
To fix test error. See component/scroll-to#9 (comment)
@tj Any chance you'd be willing to drop this tiny shortcut in favor of saving hundreds of people time in awkward workarounds? |
For people running into this with jest testing. Add this to your jest.config.js
|
@SimonSomlai I did what you mention and it works until my jest test actually triggers
|
Anybody have an answer for this? Mine isn't working on Gatsby. |
I'm using scroll-to-element in a React app that pre-renders on the server. When requiring scroll-to-element, which is dependent on scroll-to, I get
Error: Cannot find module 'tween'
.I believe this is because scroll-to requires
component-tween
viavar Tween = require('tween');
which works in browser environments because of the following in package.json.everything works fine in the client, but the application errors out when running on the server because node doesn't know what
tween
is.The text was updated successfully, but these errors were encountered: