cloudflare / workers-aws-template

Cloudflare Workers template for accessing AWS services such as DynamoDB and SQS
Apache License 2.0
124 stars 12 forks source link

Unable to generate project OR bundle the code in this repo #8

Open r14c opened 1 year ago

r14c commented 1 year ago
λ´wrangler generate projectname https://github.com/cloudflare/workers-aws-template
 ⛅️ wrangler 2.1.15 (update available 2.6.0)
------------------------------------------------------
Creating a worker in projectname from https://github.com/cloudflare/workers-aws-template

✘ [ERROR] Failed to find "undefined" in https://github.com/cloudflare/workers-aws-template.git

If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose

If i clone this repo and attempt to run the code directly

λ´wrangler dev index.js
 ⛅️ wrangler 2.1.15 (update available 2.6.0)
✘ [ERROR] Could not resolve "http2"

    node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http2-handler.js:6:24:
      6 │ const http2_1 = require("http2");
        ╵                         ~~~~~~~

  The package "http2" 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.

✘ [ERROR] Build failed with 1 error:

  node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http2-handler.js:6:24: ERROR: Could not
  resolve "http2"

I see this exact error in a project where i'm trying to use dynamo from a worker.

r14c commented 1 year ago

Digging a little more into this, looks like i need to make sure that wrangler sees only es6 versions of the aws sdk. https://github.com/cloudflare/workers-aws-template/pull/7 gave some helpful hints