Skip to content
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

🐛 BUG: Creating a new typescript project fails with an error #7226

Open
anonrig opened this issue Nov 11, 2024 · 4 comments
Open

🐛 BUG: Creating a new typescript project fails with an error #7226

anonrig opened this issue Nov 11, 2024 · 4 comments
Labels
awaiting reporter response Needs clarification or followup from OP bug Something that isn't working

Comments

@anonrig
Copy link
Member

anonrig commented Nov 11, 2024

Which Cloudflare product(s) does this pertain to?

C3 (npm create cloudflare), Wrangler

What version(s) of the tool(s) are you using?

Wrangler 3.60.3

What version of Node are you using?

22.10.0

What operating system and version are you using?

CFLinux

Describe the Bug

Observed behavior

Creating a new project using typescript preset fails to install dependencies and fails with an "Error" with no error message. And it doesn't add the workers-types dependency.

Expected behavior

We should be able to create a new project without any issues.

Steps to reproduce

Run the following commands:

  • npx wrangler init
  • Select: hello world example > hello world worker > typescript

The installation fails with "Error" without enabling Warp or any proxy.

  • Go to the newly created project
  • Run npm install (succeeds)
  • Run npm run dev (or node --run dev)

Fails with

Error: Cannot find module 'rollup-plugin-node-polyfills/polyfills/empty.js'
  • Remove node_modules folder
  • Run pnpm install
  • Run node --run dev and it succeeds.

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

@anonrig anonrig added the bug Something that isn't working label Nov 11, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Nov 11, 2024
@vicb
Copy link
Contributor

vicb commented Nov 14, 2024

Wrangler 3.60.3

Is that right? (wrangler is now 3.87.0)

Also npx wrangler init is deprecated, you should use npx create-cloudflare@latest.

Can you try with an up to date version of wrangler?

Thanks!

@anonrig
Copy link
Member Author

anonrig commented Nov 14, 2024

npx create-cloudflare@latest still fails.

❯ npx create-cloudflare@latest
Need to install the following packages:
create-cloudflare@2.32.1
Ok to proceed? (y) y


──────────────────────────────────────────────────────────────────────────────────────────────────────────
👋 Welcome to create-cloudflare v2.32.1!
🧡 Let's get started.
📊 Cloudflare collects telemetry about your usage of Create-Cloudflare.

Learn more at: https://github.com/cloudflare/workers-sdk/blob/main/packages/create-cloudflare/telemetry.md
──────────────────────────────────────────────────────────────────────────────────────────────────────────

╭ Create an application with Cloudflare Step 1 of 3
│
├ In which directory do you want to create your application?
│ dir ./test-worker
│
├ What would you like to start with?
│ category Hello World example
│
├ Which template would you like to use?
│ type Hello World Worker
│
├ Which language do you want to use?
│ lang TypeScript
│
├ Copying template files
│ files copied to project directory
│
├ Updating name in `package.json`
│ updated `package.json`
│
╰  ERROR  Error

@anonrig
Copy link
Member Author

anonrig commented Nov 14, 2024

The newly created project still doesn't have @cloudflare/worker-types dependency, which is used inside tsconfig.json

~/coding/test-worker via ⬢ v22.10.0
❯ cat package.json
{
  "name": "test-worker",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "deploy": "wrangler deploy",
    "dev": "wrangler dev",
    "start": "wrangler dev",
    "test": "vitest",
    "cf-typegen": "wrangler types"
  },
  "devDependencies": {
    "@cloudflare/vitest-pool-workers": "^0.5.2",
    "typescript": "^5.5.2",
    "vitest": "2.0.5",
    "wrangler": "^3.60.3"
  }
}%

@vicb
Copy link
Contributor

vicb commented Nov 15, 2024

@anonrig This is where your install error:

[...]
├ Updating name in `package.json`
│ updated `package.json`
│
╰  ERROR  Error

What I have on MacOS, with the same c3 version:

[...]
├ Updating name in `package.json`
│ updated `package.json`
│
├ Installing dependencies
│ installed via `npm install`
│
╰ Application created

╭ Configuring your application for Cloudflare Step 2 of 3
│
├ Installing @cloudflare/workers-types
│ installed via npm
│
├ Adding latest types to `tsconfig.json`
│ added @cloudflare/workers-types/2023-07-01
│
├ Retrieving current workerd compatibility date
│ compatibility date 2024-11-12

Any chance you have more logs?
If not, what happens if you:

cd test-worker
npm i

@andyjessop andyjessop added the awaiting reporter response Needs clarification or followup from OP label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reporter response Needs clarification or followup from OP bug Something that isn't working
Projects
Status: Untriaged
Development

No branches or pull requests

3 participants