It looks like you're trying to run the JS file directly with Node? If so you'll need to use Wrangler
It looks like you're trying to run the JS file directly with Node? If so you'll need to use Wrangler.
.vscode/launch.json :tsconfigpackage.jsontsc directly.wrangler dev in order to run the JS file.start script)tsc outputs a Javascript file. But you can't run that Javascript file directly with Node.js, it's not compatible.<path>/bin/node ./out/index.js which makes it seem like you're running it directly with Node.

.vscode/launch.jsontsconfigtsctscwrangler devstart<path>/bin/node ./out/index.js{
"configurations": [
{
"name": "hybrid-routing",
"type": "node",
"request": "launch",
"sourceMaps": true,
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/index.ts",
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "tsc: build - tsconfig.json",
}
]
}{
"compilerOptions": {
"types": [
"@cloudflare/workers-types",
"vitest-environment-miniflare/globals",
],
"target": "ES2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": ["ES2020"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"module": "NodeNext", /* Specify what module code is generated. */
"rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "nodenext", /* Specify how TypeScript looks up a file from a given module specifier. */
"baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
"outDir": "./out", /* Specify an output folder for all emitted files. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"strict": true, /* Enable all strict type-checking options. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}{
"name": "cxp-uwp2-int",
"type": "module",
"private": true,
"version": "1.0.0",
"description": "package for creating workers templates",
"main": "./index.ts",
"scripts": {
"test": "vitest --watch",
"start": "wrangler dev --local --port 3012 --env local",
"wrangler:tail": "wrangler tail",
"format": "prettier --write '**/*.{js,css,json,md}'",
"compile": "tsc"
},
"author": "{{ authors }}",
"license": "ISC",
"devDependencies": {
"@cloudflare/workers-types": "^4.20230404.0",
"@types/jest": "^29.5.0",
"@vitest/ui": "^0.29.8",
"msw": "^1.2.1",
"prettier": "^2.8.7",
"vite": "^4.5.2",
"vitest": "^0.29.8",
"vitest-environment-miniflare": "^2.13.0"
},
"dependencies": {
"itty-router": "^3.0.12",
"serverless-cloudflare-workers": "^1.2.0",
"typescript": "^5.0.3",
"wrangler": "^2.20.2"
}
}