H
HonoFranz3

Failed to load .env file ".env": Error: ENOENT: no such file or directory

Hey, Im new to using cloudflare and new to using Hono. I now came across an error that tells me Im missing a .env file, which also should contain some variables. The problem is, idk where I use these and what their values should be. It seems like these should be using system variables instead (Im currently on Windows 10), but I could find an answer online. This only started appearing after I added and tried using Hono. Here is my code:
import { Hono } from "hono";
import { testFeed } from "./createRssFeed";

const app = new Hono();

app.get("/", async content => {
content.header("Content-Type", "application/atom+xml");
content.header("Cache-Control", "no-cache");

const feed = testFeed();
return content.body(feed);
});
export default app;
import { Hono } from "hono";
import { testFeed } from "./createRssFeed";

const app = new Hono();

app.get("/", async content => {
content.header("Content-Type", "application/atom+xml");
content.header("Cache-Control", "no-cache");

const feed = testFeed();
return content.body(feed);
});
export default app;
The wrangler.toml file:
name = "qmj-atom-feed"
main = "src/index.ts"
compatibility_date = "2024-04-19"
compatibility_flags = ["nodejs_compat"]
name = "qmj-atom-feed"
main = "src/index.ts"
compatibility_date = "2024-04-19"
compatibility_flags = ["nodejs_compat"]
Franz3
Franz318d ago
The console output:
npm start

> qmj-atom-feed@0.0.0 start
> wrangler dev

⛅️ wrangler 3.51.2 (update available 3.53.0)
-------------------------------------------------------
[wrangler:inf] Ready on http://127.0.0.1:8787
X [ERROR] Could not resolve "path"

node_modules/dotenv/lib/main.js:2:21:
2 │ const path = require('path')
╵ ~~~~~~

The package "path" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.


X [ERROR] Could not resolve "os"

node_modules/dotenv/lib/main.js:3:19:
3 │ const os = require('os')
╵ ~~~~

The package "os" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.


X [ERROR] Could not resolve "crypto"

node_modules/dotenv/lib/main.js:4:23:
4 │ const crypto = require('crypto')
╵ ~~~~~~~~

The package "crypto" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.


X [ERROR] Could not resolve "string_decoder"

node_modules/sax/lib/sax.js:234:25:
234 │ var SD = require('string_decoder').StringDecoder
╵ ~~~~~~~~~~~~~~~~

The package "string_decoder" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.


[b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit
X [ERROR] Failed to build
npm start

> qmj-atom-feed@0.0.0 start
> wrangler dev

⛅️ wrangler 3.51.2 (update available 3.53.0)
-------------------------------------------------------
[wrangler:inf] Ready on http://127.0.0.1:8787
X [ERROR] Could not resolve "path"

node_modules/dotenv/lib/main.js:2:21:
2 │ const path = require('path')
╵ ~~~~~~

The package "path" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.


X [ERROR] Could not resolve "os"

node_modules/dotenv/lib/main.js:3:19:
3 │ const os = require('os')
╵ ~~~~

The package "os" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.


X [ERROR] Could not resolve "crypto"

node_modules/dotenv/lib/main.js:4:23:
4 │ const crypto = require('crypto')
╵ ~~~~~~~~

The package "crypto" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.


X [ERROR] Could not resolve "string_decoder"

node_modules/sax/lib/sax.js:234:25:
234 │ var SD = require('string_decoder').StringDecoder
╵ ~~~~~~~~~~~~~~~~

The package "string_decoder" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.


[b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit
X [ERROR] Failed to build
And the logs:
--- 2024-05-01T02:15:30.932Z debug
🪵 Writing logs to "C:\Users\Franz3\AppData\Roaming\xdg.config\.wrangler\logs\wrangler-2024-05-01_02-15-30_592.log"
---

--- 2024-05-01T02:15:30.932Z debug
Failed to load .env file ".env": Error: ENOENT: no such file or directory, open 'C:\Users\Franz3\VSC\qmj-atom-feed\.env'
at Object.open (node:internal/fs/sync:78:18)
at Object.openSync (node:fs:565:17)
at Object.readFileSync (node:fs:445:35)
at tryLoadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124900:72)
at loadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124909:12)
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:167346:20
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:132327:16
at maybeAsyncResult (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:130548:44)
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:132326:14
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:130535:22 {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Users\\Franz3\\VSC\\qmj-atom-feed\\.env'
}
---

--- 2024-05-01T02:15:30.946Z log
⛅️ wrangler 3.51.2 (update available 3.53.0)
-------------------------------------------------------
---

--- 2024-05-01T02:15:31.017Z debug
Retrieving cached values for userId from node_modules\.cache\wrangler
---

--- 2024-05-01T02:15:31.017Z debug
Metrics dispatcher: Dispatching disabled - would have sent {"type":"event","name":"run dev","properties":{"local":true,"usesTypeScript":true}}.
---
--- 2024-05-01T02:15:30.932Z debug
🪵 Writing logs to "C:\Users\Franz3\AppData\Roaming\xdg.config\.wrangler\logs\wrangler-2024-05-01_02-15-30_592.log"
---

--- 2024-05-01T02:15:30.932Z debug
Failed to load .env file ".env": Error: ENOENT: no such file or directory, open 'C:\Users\Franz3\VSC\qmj-atom-feed\.env'
at Object.open (node:internal/fs/sync:78:18)
at Object.openSync (node:fs:565:17)
at Object.readFileSync (node:fs:445:35)
at tryLoadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124900:72)
at loadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124909:12)
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:167346:20
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:132327:16
at maybeAsyncResult (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:130548:44)
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:132326:14
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:130535:22 {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Users\\Franz3\\VSC\\qmj-atom-feed\\.env'
}
---

--- 2024-05-01T02:15:30.946Z log
⛅️ wrangler 3.51.2 (update available 3.53.0)
-------------------------------------------------------
---

--- 2024-05-01T02:15:31.017Z debug
Retrieving cached values for userId from node_modules\.cache\wrangler
---

--- 2024-05-01T02:15:31.017Z debug
Metrics dispatcher: Dispatching disabled - would have sent {"type":"event","name":"run dev","properties":{"local":true,"usesTypeScript":true}}.
---
--- 2024-05-01T02:15:31.018Z debug
Failed to load .env file "C:\Users\Franz3\VSC\qmj-atom-feed\.dev.vars": Error: ENOENT: no such file or directory, open 'C:\Users\Franz3\VSC\qmj-atom-feed\.dev.vars'
at Object.open (node:internal/fs/sync:78:18)
at Object.openSync (node:fs:565:17)
at Object.readFileSync (node:fs:445:35)
at tryLoadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124900:72)
at loadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124909:12)
at getVarsForDev (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:164783:18)
at getBindings (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172596:10)
at getBindingsAndAssetPaths (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172481:20)
at getDevReactElement (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172153:40)
at startDev (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172217:60) {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Users\\Franz3\\VSC\\qmj-atom-feed\\.dev.vars'
}
---
--- 2024-05-01T02:15:31.018Z debug
Failed to load .env file "C:\Users\Franz3\VSC\qmj-atom-feed\.dev.vars": Error: ENOENT: no such file or directory, open 'C:\Users\Franz3\VSC\qmj-atom-feed\.dev.vars'
at Object.open (node:internal/fs/sync:78:18)
at Object.openSync (node:fs:565:17)
at Object.readFileSync (node:fs:445:35)
at tryLoadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124900:72)
at loadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124909:12)
at getVarsForDev (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:164783:18)
at getBindings (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172596:10)
at getBindingsAndAssetPaths (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172481:20)
at getDevReactElement (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172153:40)
at startDev (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172217:60) {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Users\\Franz3\\VSC\\qmj-atom-feed\\.dev.vars'
}
---
The goal of this worker would be to serve an rss feed and when I add node_compat = true to the wrangler.toml file, this is the new output: Console:
wrangler dev

⛅️ wrangler 3.51.2 (update available 3.53.0)
-------------------------------------------------------
▲ [WARNING] Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details.



X [ERROR] The `nodejs_compat` compatibility flag cannot be used in conjunction with the legacy `--node-compat` flag. If you want to use the Workers runtime Node.js compatibility features, please remove the `--node-compat` argument from your CLI command or `node_compat = true` from your config file.
wrangler dev

⛅️ wrangler 3.51.2 (update available 3.53.0)
-------------------------------------------------------
▲ [WARNING] Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details.



X [ERROR] The `nodejs_compat` compatibility flag cannot be used in conjunction with the legacy `--node-compat` flag. If you want to use the Workers runtime Node.js compatibility features, please remove the `--node-compat` argument from your CLI command or `node_compat = true` from your config file.
Logs
--- 2024-05-01T02:22:09.690Z debug
🪵 Writing logs to "C:\Users\Franz3\AppData\Roaming\xdg.config\.wrangler\logs\wrangler-2024-05-01_02-22-09_359.log"
---

--- 2024-05-01T02:22:09.690Z debug
Failed to load .env file ".env": Error: ENOENT: no such file or directory, open 'C:\Users\Franz3\VSC\qmj-atom-feed\.env'
at Object.open (node:internal/fs/sync:78:18)
at Object.openSync (node:fs:565:17)
at Object.readFileSync (node:fs:445:35)
at tryLoadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124900:72)
at loadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124909:12)
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:167346:20
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:132327:16
at maybeAsyncResult (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:130548:44)
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:132326:14
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:130535:22 {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Users\\Franz3\\VSC\\qmj-atom-feed\\.env'
}
---

--- 2024-05-01T02:22:09.704Z log
⛅️ wrangler 3.51.2 (update available 3.53.0)
-------------------------------------------------------
---
--- 2024-05-01T02:22:09.690Z debug
🪵 Writing logs to "C:\Users\Franz3\AppData\Roaming\xdg.config\.wrangler\logs\wrangler-2024-05-01_02-22-09_359.log"
---

--- 2024-05-01T02:22:09.690Z debug
Failed to load .env file ".env": Error: ENOENT: no such file or directory, open 'C:\Users\Franz3\VSC\qmj-atom-feed\.env'
at Object.open (node:internal/fs/sync:78:18)
at Object.openSync (node:fs:565:17)
at Object.readFileSync (node:fs:445:35)
at tryLoadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124900:72)
at loadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124909:12)
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:167346:20
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:132327:16
at maybeAsyncResult (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:130548:44)
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:132326:14
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:130535:22 {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Users\\Franz3\\VSC\\qmj-atom-feed\\.env'
}
---

--- 2024-05-01T02:22:09.704Z log
⛅️ wrangler 3.51.2 (update available 3.53.0)
-------------------------------------------------------
---
Nico
Nico18d ago
On cloudflare workers you want to use .dev.vars for environment variables You can use the dotenv package you can access the variables inside context only on c.env
Nico
Nico18d ago
GitHub
GitHub - NicoPlyley/hono-auth: An example app with authentication u...
An example app with authentication using Hono, Drizzle, and D1. Running on CF Workers - NicoPlyley/hono-auth
Nico
Nico18d ago
Here is an example cf workers api
Franz3
Franz317d ago
thanks for the response. My problem is not that I want to use environment variables in my code. I have the problem that I cant build/ test my worker locally after I tried using Hono. The error says it is something with environment variables, but I don't use environment variables in my code. My problem is that I don't understand how to get rid of this error so that it builds/ works locally locally again. I want to fix this bug/ error, not implement environment variables.
Nico
Nico17d ago
Can you show me your package.json
Franz3
Franz317d ago
Here you go:
{
"name": "qmj-atom-feed",
"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.1.0",
"@cloudflare/workers-types": "^4.20240419.0",
"@types/jest": "^29.5.12",
"feed": "^4.2.2",
"typescript": "^5.0.4",
"vitest": "^1.3.0",
"wrangler": "^3.0.0"
},
"dependencies": {
"@hono/node-server": "^1.11.0",
"discord.js-selfbot-v13": "^3.1.4",
"dotenv": "^16.4.5",
"hono": "^4.2.5"
}
}
{
"name": "qmj-atom-feed",
"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.1.0",
"@cloudflare/workers-types": "^4.20240419.0",
"@types/jest": "^29.5.12",
"feed": "^4.2.2",
"typescript": "^5.0.4",
"vitest": "^1.3.0",
"wrangler": "^3.0.0"
},
"dependencies": {
"@hono/node-server": "^1.11.0",
"discord.js-selfbot-v13": "^3.1.4",
"dotenv": "^16.4.5",
"hono": "^4.2.5"
}
}
Nico
Nico17d ago
So your dependency for dotenv is likely causing the issue. Is not compatible with cf workers It attempts to use file system which is a node specific library that is not supported
Franz3
Franz317d ago
I see if I remove it, it still doesn't work though
Nico
Nico17d ago
Possible the @hono/node-server is also not working Make sure you do a bun/npm remove package-name and not just delete those lines of code
Franz3
Franz317d ago
oh ya, someone told me to adding that to fix that bug, idk, I shouldn't need it
Nico
Nico17d ago
Only if your running the application with node you would need that
Franz3
Franz317d ago
I removed the dotenv and node-server with npm and it still fails
X [ERROR] Could not resolve "string_decoder"

node_modules/sax/lib/sax.js:234:25:
234 │ var SD = require('string_decoder').StringDecoder
╵ ~~~~~~~~~~~~~~~~

The package "string_decoder" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.


X [ERROR] Could not resolve "dotenv"

src/index.ts:3:8:
3 │ require('dotenv').config();
╵ ~~~~~~~~

You can mark the path "dotenv" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time
X [ERROR] Could not resolve "string_decoder"

node_modules/sax/lib/sax.js:234:25:
234 │ var SD = require('string_decoder').StringDecoder
╵ ~~~~~~~~~~~~~~~~

The package "string_decoder" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.


X [ERROR] Could not resolve "dotenv"

src/index.ts:3:8:
3 │ require('dotenv').config();
╵ ~~~~~~~~

You can mark the path "dotenv" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time
Logs:
--- 2024-05-02T00:18:14.040Z debug
🪵 Writing logs to "C:\Users\Franz3\AppData\Roaming\xdg.config\.wrangler\logs\wrangler-2024-05-02_00-18-13_710.log"
---

--- 2024-05-02T00:18:14.040Z debug
Failed to load .env file ".env": Error: ENOENT: no such file or directory, open 'C:\Users\Franz3\VSC\qmj-atom-feed\.env'
at Object.open (node:internal/fs/sync:78:18)
at Object.openSync (node:fs:565:17)
at Object.readFileSync (node:fs:445:35)
at tryLoadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124900:72)
at loadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124909:12)
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:167346:20
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:132327:16
at maybeAsyncResult (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:130548:44)
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:132326:14
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:130535:22 {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Users\\Franz3\\VSC\\qmj-atom-feed\\.env'
}
---

--- 2024-05-02T00:18:14.055Z log
⛅️ wrangler 3.51.2 (update available 3.53.0)
-------------------------------------------------------
---

--- 2024-05-02T00:18:14.126Z debug
Retrieving cached values for userId from node_modules\.cache\wrangler
---

--- 2024-05-02T00:18:14.126Z debug
Metrics dispatcher: Dispatching disabled - would have sent {"type":"event","name":"run dev","properties":{"local":true,"usesTypeScript":true}}.
---
--- 2024-05-02T00:18:14.040Z debug
🪵 Writing logs to "C:\Users\Franz3\AppData\Roaming\xdg.config\.wrangler\logs\wrangler-2024-05-02_00-18-13_710.log"
---

--- 2024-05-02T00:18:14.040Z debug
Failed to load .env file ".env": Error: ENOENT: no such file or directory, open 'C:\Users\Franz3\VSC\qmj-atom-feed\.env'
at Object.open (node:internal/fs/sync:78:18)
at Object.openSync (node:fs:565:17)
at Object.readFileSync (node:fs:445:35)
at tryLoadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124900:72)
at loadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124909:12)
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:167346:20
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:132327:16
at maybeAsyncResult (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:130548:44)
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:132326:14
at C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:130535:22 {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Users\\Franz3\\VSC\\qmj-atom-feed\\.env'
}
---

--- 2024-05-02T00:18:14.055Z log
⛅️ wrangler 3.51.2 (update available 3.53.0)
-------------------------------------------------------
---

--- 2024-05-02T00:18:14.126Z debug
Retrieving cached values for userId from node_modules\.cache\wrangler
---

--- 2024-05-02T00:18:14.126Z debug
Metrics dispatcher: Dispatching disabled - would have sent {"type":"event","name":"run dev","properties":{"local":true,"usesTypeScript":true}}.
---
--- 2024-05-02T00:18:14.127Z debug
Failed to load .env file "C:\Users\Franz3\VSC\qmj-atom-feed\.dev.vars": Error: ENOENT: no such file or directory, open 'C:\Users\Franz3\VSC\qmj-atom-feed\.dev.vars'
at Object.open (node:internal/fs/sync:78:18)
at Object.openSync (node:fs:565:17)
at Object.readFileSync (node:fs:445:35)
at tryLoadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124900:72)
at loadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124909:12)
at getVarsForDev (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:164783:18)
at getBindings (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172596:10)
at getBindingsAndAssetPaths (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172481:20)
at getDevReactElement (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172153:40)
at startDev (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172217:60) {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Users\\Franz3\\VSC\\qmj-atom-feed\\.dev.vars'
}
---
--- 2024-05-02T00:18:14.127Z debug
Failed to load .env file "C:\Users\Franz3\VSC\qmj-atom-feed\.dev.vars": Error: ENOENT: no such file or directory, open 'C:\Users\Franz3\VSC\qmj-atom-feed\.dev.vars'
at Object.open (node:internal/fs/sync:78:18)
at Object.openSync (node:fs:565:17)
at Object.readFileSync (node:fs:445:35)
at tryLoadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124900:72)
at loadDotEnv (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:124909:12)
at getVarsForDev (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:164783:18)
at getBindings (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172596:10)
at getBindingsAndAssetPaths (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172481:20)
at getDevReactElement (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172153:40)
at startDev (C:\Users\Franz3\VSC\qmj-atom-feed\node_modules\wrangler\wrangler-dist\cli.js:172217:60) {
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Users\\Franz3\\VSC\\qmj-atom-feed\\.dev.vars'
}
---
Nico
Nico17d ago
It still stays dotenv so I wonder if that discord package is using it
Franz3
Franz317d ago
maybe
Nico
Nico17d ago
Did you remove the dotenv on line 3 on index.ts?
Franz3
Franz317d ago
there never was no dotenv, idk what you mean
No description
Nico
Nico17d ago
That’s weird, remove your .wrangler folder and reinstall wrangler It has a glitch on it somewhere. Does anything in createRssFeed.ts use an external package? Or better yet I’d delete the node modules and do a fresh install of all packages
Franz3
Franz317d ago
ok, I will try that
Nico
Nico17d ago
Also you don’t have a file on your dev and start commands so wrangler dev src/index.ts Also you can update your deploy as well wrangler deploy --minify src/index.ts
Franz3
Franz317d ago
I removed the wrangler config and the node modules folder, after that I ran these commands: npm install wrangler --save-dev npm i feed npm i discord.js-selfbot-v13 npm i hono
npx wrangler dev src/index.ts
⛅️ wrangler 3.53.0
-------------------
X [ERROR] Could not resolve "string_decoder"

node_modules/sax/lib/sax.js:234:25:
234 │ var SD = require('string_decoder').StringDecoder
╵ ~~~~~~~~~~~~~~~~

The package "string_decoder" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.


X [ERROR] Could not resolve "dotenv"

src/index.ts:3:8:
3 │ require('dotenv').config();
╵ ~~~~~~~~

You can mark the path "dotenv" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.


[b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit
X [ERROR] Failed to build


🪵 Logs were written to "C:\Users\Franz3\AppData\Roaming\xdg.config\.wrangler\logs\wrangler-2024-05 -02_00-41-57_601.log"

Franz3@DESKTOP-CCJAUN6 MINGW64 ~/VSC/qmj-atom-feed (master)
$ npx wrangler deploy --minify src/index.ts
⛅️ wrangler 3.53.0
-------------------

X [ERROR] A compatibility_date is required when publishing. Add the following to your wrangler.toml file:.


compatibility_date = "2024-05-02"

Or you could pass it in your terminal as `--compatibility-date 2024-05-02`
See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information.


:wood: Logs were written to "C:\Users\Franz3\AppData\Roaming\xdg.config\.wrangler\logs\wrangler-2024-05 -02_00-42-12_843.log"
npx wrangler dev src/index.ts
⛅️ wrangler 3.53.0
-------------------
X [ERROR] Could not resolve "string_decoder"

node_modules/sax/lib/sax.js:234:25:
234 │ var SD = require('string_decoder').StringDecoder
╵ ~~~~~~~~~~~~~~~~

The package "string_decoder" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.


X [ERROR] Could not resolve "dotenv"

src/index.ts:3:8:
3 │ require('dotenv').config();
╵ ~~~~~~~~

You can mark the path "dotenv" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.


[b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit
X [ERROR] Failed to build


🪵 Logs were written to "C:\Users\Franz3\AppData\Roaming\xdg.config\.wrangler\logs\wrangler-2024-05 -02_00-41-57_601.log"

Franz3@DESKTOP-CCJAUN6 MINGW64 ~/VSC/qmj-atom-feed (master)
$ npx wrangler deploy --minify src/index.ts
⛅️ wrangler 3.53.0
-------------------

X [ERROR] A compatibility_date is required when publishing. Add the following to your wrangler.toml file:.


compatibility_date = "2024-05-02"

Or you could pass it in your terminal as `--compatibility-date 2024-05-02`
See https://developers.cloudflare.com/workers/platform/compatibility-dates for more information.


:wood: Logs were written to "C:\Users\Franz3\AppData\Roaming\xdg.config\.wrangler\logs\wrangler-2024-05 -02_00-42-12_843.log"
it also doesnt seem like the wrangler config got generated again, I assume thats one part of the problem
Nico
Nico17d ago
Some package must not be compatible it’s so weird it says in your index file It just be from the import of the rss file something in there is causing it but it’s not mapping right
Franz3
Franz317d ago
now, idk why, feed is not recognized
No description
Nico
Nico17d ago
Can you comment out everything on rss. Return just a string and then we can verify it’s coming from a package So don’t import anything on your index
Franz3
Franz317d ago
🥳
No description
Franz3
Franz317d ago
do I have to initialize wrangler with npx wrangler init again here?
Nico
Nico17d ago
I don’t believe you do That’s only for setting up a project with a framework I believe So something in feed has an issue I would try and find an alternative that works on edge platforms
Franz3
Franz317d ago
yes, thats what I assumed, but the wrangler config is not there now yes, I will look into that. Thanks a lot for the help. What exactly do you mean with "that works on edge platforms" though?
Nico
Nico17d ago
Most edge/serverless platforms don’t use node. They just use the chrome v8 engine. So if a package has node libraries it won’t work
Nico
Nico17d ago
Cloudflare Docs
Node.js compatibility · Cloudflare Workers docs
Implemented Node.js runtime APIs and enablement instructions for your Worker project.
Nico
Nico17d ago
So these are the only ones compatible with cf workers
Nico
Nico17d ago
npm
rss-parser
A lightweight RSS parser, for Node and the browser. Latest version: 3.13.0, last published: a year ago. Start using rss-parser in your project by running npm i rss-parser. There are 325 other projects in the npm registry using rss-parser.
Nico
Nico17d ago
This appears to work on cf wokers. Since it can run in web it should have any dependencies that require node
Franz3
Franz317d ago
I see, thats why it told me to add node_compat = true to the config
Nico
Nico17d ago
Actually you can use your rss one. I didn’t not realize String Decoder was available on cf workers So add this to your wrangler.toml compatibility_flags = [ "nodejs_compat" ]
Franz3
Franz317d ago
I dont have a wrangler.toml. also, thats what I had last time too
Nico
Nico17d ago
Just create on in your root folder
Nico
Nico17d ago
Nico
Nico17d ago
Copy this one. Just add project name
Franz3
Franz317d ago
done, I still have an issue with importing feed and idk why
No description
Nico
Nico17d ago
What does the issue say
Franz3
Franz317d ago
Cannot find module 'feed' or its corresponding type declarations
Nico
Nico17d ago
Might be an error with the code editor Sometimes they don’t update So no guarantee this will make it work because it might still be trying to use dotenv but we’ll see
Franz3
Franz317d ago
ok, so should I try restarting the local dev instance with the rssFeed code included again?
X [ERROR] Could not resolve "string_decoder"

node_modules/sax/lib/sax.js:234:25:
234 │ var SD = require('string_decoder').StringDecoder
╵ ~~~~~~~~~~~~~~~~

The package "string_decoder" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.
X [ERROR] Could not resolve "string_decoder"

node_modules/sax/lib/sax.js:234:25:
234 │ var SD = require('string_decoder').StringDecoder
╵ ~~~~~~~~~~~~~~~~

The package "string_decoder" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.
Franz3
Franz317d ago
Nico
Nico17d ago
Did you restart the reload the wrangler.toml file?
Franz3
Franz317d ago
how do I do that?
Nico
Nico17d ago
Just stop wrangler and start it again The toml file is not hot reloaded
Franz3
Franz317d ago
how do I stop it? isnt that done by using x to close the local dev environment and start it again with npx wrangler dev src/index.ts? cause that is what I did else, I dont know how to stop wrangler
Nico
Nico17d ago
Yup that would be right
Franz3
Franz317d ago
well, then these are the logs I get from that btw, after restarting the ide, the import error went awai, so thats fine
Nico
Nico17d ago
So it’s working now?
Franz3
Franz317d ago
no
npx wrangler dev src/index.ts
⛅️ wrangler 3.53.0
-------------------
X [ERROR] Could not resolve "string_decoder"

node_modules/sax/lib/sax.js:234:25:
234 │ var SD = require('string_decoder').StringDecoder
╵ ~~~~~~~~~~~~~~~~

The package "string_decoder" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.


╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit │╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
X [ERROR] Failed to build
npx wrangler dev src/index.ts
⛅️ wrangler 3.53.0
-------------------
X [ERROR] Could not resolve "string_decoder"

node_modules/sax/lib/sax.js:234:25:
234 │ var SD = require('string_decoder').StringDecoder
╵ ~~~~~~~~~~~~~~~~

The package "string_decoder" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.


╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit │╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
X [ERROR] Failed to build
it fails to build it seems something uses string_decoder which is part of that nodejs server
Nico
Nico17d ago
I’m not sure why it says it’s available
Nico
Nico17d ago
No description
Franz3
Franz317d ago
does that mean the solution would be to find another module with which I can create an atom feed, that doesn't use nodejs server modules? How can I tell if a module is doing that?
Nico
Nico17d ago
Yes that would be best. I sent one earlier that appears to work on cf workers This one here If they advertise it works on a browser then it should all work in cf
Franz3
Franz315d ago
Alright, I will give it a shot, thanks a lot Hey, this is a package to parse an rss feed, but I want to create an rss feed and serve it with my worker. Is it correct that I only have to look out for it being compatible with the chrome v8 engine? This linked rss parser for example, also lists nodejs, so I am confused about how I can tell if a package is compatible or not. Thanks a lot for the help and sorry for the beginner questions
Nico
Nico15d ago
It’s no worries. Most packages don’t advertise it being available for v8. But if they are browser compatible or you use import them using a script tag then they should work on cf workers
Franz3
Franz315d ago
they would have to tell you that they are browser compatible for me to know, or is there another way to tell besides trying it out?
or you use import them using a script tag then they should work on cf workers
do you mean that I can also use nodejs packages if I import themwith a script tag? I dont know how I would do that in workers though, as that sounds like html, which would be cf pages if I understand this correctly
Nico
Nico15d ago
I’m just meant if they have an option to use a script tag then they don’t use node libraries Honestly I don’t know if a great way to check there might be a website out there. But I’ll look later today see if I find anything
Franz3
Franz315d ago
amazing, thanks a lot for the help. I will also keep an eye open
Want results from more Discord servers?
Add your server
More Posts
executionCtx.waitUntil on write serviceI have a worker that I want to call an external api on, but I want to return a response without awaiDoes Hono JSX do client-side hydration?I.e. are client events like on:click meant to work? And if not, how can it be enabled / done in otheStreamSSE on http2Hi ! It seems that the streamSSE feature is not correctly adapted to work on http2. It adds the follOptional params in hono/clientIt seems that it doesn't support optional params at all. In hono I can specify optional parameters, Send data to HonoHi, how can i send Request body and file on same route.Client ipHow can I get the client ip, I need it for my rate limiterWhat is the best way to handle the error?What I want is to get the error from server to client using rpc + react query 1. Using `trycatch` 2Running `bun run dev` on a newly created Cloudflare Pages example spits an error``` bun run dev $ vite (!) Could not auto-determine entry point from rollupOptions or html files andconnect my hono application endpoints with swagger uihow i can use swagger ui with my hono applicationHow to set "credentials: true" in client side using rpc?I'm using rpc with react query on the client side, this kind of fetching has already credentials: trCookies doesn't processWhen I try to run in my middleware the following ``` setCookie(c, 'test', 'res', { maxAge: 60 * 60 use Context to get vars from wrangler.tomlhow can fix this code. i want to use my openaiApiKey from the wrangler.toml when i create an openai Connect Hono Cloudflare with MongoDBHi. I am using Hono and deploying to Cloudflare. However I am unable to find a way to connect mongodCase insensitive query paramsWe are using hono-zod-openapi to replace an existing API. Sadly the old API (written in ASP.Net) appPassword hashingHow to hash password?How to setup Hono with Remix/Cloudflare for Vite dev server?From the documentation for Cloudflare Pages, there is an adapter and a plugin, but it is not clear hValidate response objectsUsing the zod validator middleware it is possible to validate params , query, request body like: ``Hono Oauth Provider with JWT issueHey everyone! I'm not sure if this is the right place for me to post about this but recently I wanteDeploy Hono / Bun APII know, I know this is such a newby question but I come from small express apps and other simple ‘clIs there a way to list all request headers ?I have this use case where I am not sure which header key is being sent, I would like to log all hea