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.

🐛 BUG: Bundling with Stripe and other packages leads to unclear error hint

See original GitHub issue

What version of Wrangler are you using?

0.0.27

What operating system are you using?

Mac

Describe the Bug

I’m attempting to upload a bundle with the Stripe npm package and Durable Objects. But when attempting to upload, am getting error messages like these:

✘ [ERROR] Could not resolve "crypto"

    node_modules/stripe/lib/utils.js:5:23:
      5 │ const crypto = require('crypto');
        ╵                        ~~~~~~~~

  The package "crypto" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

However, these do not specify where the platform: ‘node’ should be used (I have tried at various locations in wrangler.toml, webpack.config.js, and package.json, but nothing has worked so far)

The webpack config is below

const path = require('path');
const webpack = require("webpack");

module.exports = {
  // target: "javascript",
  entry: "./src/index.js",
  mode: "production",
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: "worker.js"
  },
  resolve: {
    extensions: ['.ts', '.tsx', '.js', '.mjs'],
    fallback: { 
      "child_process": false,
      "http": false,
      "https": false,
      "buffer": require.resolve("buffer"),
      "crypto": require.resolve("crypto-browserify"),
      "events": require.resolve("events"),
      "path": require.resolve("path-browserify"),
      "stream": require.resolve("stream-browserify"),
    }
  },
  plugins: [
    new webpack.DefinePlugin({
      STRIPE_API_KEY: JSON.stringify(process.env.STRIPE_API_KEY)
    }),
    new webpack.ProvidePlugin({
      // Polyfill Node behavior of Buffer being available at the global level.
      Buffer: ['buffer', 'Buffer'],
    }), 
  ]
};

Any help would be very much appreciated. Thanks!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
threepointonecommented, May 4, 2022

We published 0.0.28 that introduces a new experimental node_compat config / --node-compat flag. This might just fix issues with importing stripe and other packages that have dependencies on node builtins. Feel free to give it a spin, and let us know if you have an feedback or issues!

1reaction
rishsrivcommented, Apr 28, 2022

Got it, thank you @petebacondarwin and @threepointone! Appreciate the responses. Will just wait for 2.1 then, I have offloaded Stripe authentication as a microservice in a VM for now.

Thanks again for the awesome work on this – working with wrangler2 has been a way better experience than wrangler. Better error hints ftw!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handle errors | Stripe Documentation
If an immediate problem prevents an API call from continuing, the Stripe Ruby library raises an exception. It's a best practice to catch...
Read more >
Bug: SPM error: Tuist doesn't generate the derived file Bundle ...
I'm using SPM to download Stripe dependency in an M1. I've experimented an error building the StripeCore. Seems like Tuist doesn't generate the ......
Read more >
Bug listing with status RESOLVED with ... - Gentoo's Bugzilla
... Bug:24007 - "Trying to emerge gnome, and some other packages and I always get the same kind of compiling error." status:RESOLVED resolution:WORKSFORME ......
Read more >
Error while installing "payum/stripe:*@stable" - Stack Overflow
however i got this error message: Your requirements could not be resolved to an installable set of packages. ... - Conclusion: don't install...
Read more >
Known issues with PaperCut MF, NG, Hive, Pocket and ...
When the Print Deploy client installs Mobility Print queues imported using the wizard on Windows machines, an error occurs during installation on some...
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