u_flex
u_flex11mo ago

error: No config file found in VS Code

I'm new in Deno and in coding, and need help with the following issue. I have installed Deno through VS Code terminal and when I'm trying to run deno start task getting error: No config file found, also when trying to run deno run --allow-net --allow-read ./src/index.ts getting error: Module not found "file:///C:/Users/User/Documents/VS%20Code%20Projects/src/index.ts" message. RN I'm in the process of learning Google Analytics 4 and I'm trying to run local web server according to https://github.com/googleanalytics/ga4-tutorials/blob/main/README.md
GitHub
ga4-tutorials/README.md at main · googleanalytics/ga4-tutorials
Contribute to googleanalytics/ga4-tutorials development by creating an account on GitHub.
13 Replies
marvinh.
marvinh.11mo ago
When running deno task start deno looks file a deno.json or deno.jsonc file in the current directory. Inside this config file you can define some common tasks for your project, which is typically done to save some typing. In this case you're trying to run a task named start with your command. An example of how such a config file might like:
{
"tasks": {
"start": "deno run -A my-file.ts"
}
}
{
"tasks": {
"start": "deno run -A my-file.ts"
}
}
But in your case it looks like such a file doesn't even exist. So deno throws a "no config file found" error. Common mistakes are that you're executing the command in the wrong folder. Regarding to the other "Module not found" error: That error is thrown when the requested file doesn't exist on your file system. There simply isn't a file at C:/Users/User/Documents/VS Code Projects/src/index.ts . Could be that you typed the path wrong or you are in the wrong directory. If you cloned the linked ga4-tutorials repository you need to move into the project folder in your shell to be able to run the commands. It looks like that's the cause for both of the errors you're seeing
u_flex
u_flex11mo ago
Thanks for the detailed explanation, it was very helpful. But, now I'm getting Error: Syntax error in file name, folder name, or volume label. (os error 123): lstat 'C:\C:\Users\User\Documents\VS%20Code%20Projects\ga4-tutorials-main\src\public\index.et
marvinh.
marvinh.11mo ago
huh why are there duplicate path segments? C:\C:\ looks super wrong
u_flex
u_flex11mo ago
In the process of connecting to http://localhost:80/ I'm getting error message as I stated above
No description
marvinh.
marvinh.11mo ago
Do you have a repo we can take a look at?
u_flex
u_flex11mo ago
GitHub
GitHub - googleanalytics/ga4-tutorials
Contribute to googleanalytics/ga4-tutorials development by creating an account on GitHub.
marvinh.
marvinh.11mo ago
Works fine for me. These are the steps I did
No description
marvinh.
marvinh.11mo ago
No description
u_flex
u_flex11mo ago
I've repeated every step according to the screenshot above but keep getting this error
No description
marvinh.
marvinh.11mo ago
maybe the messed something up when it comes to windows. Can check later today when I'm back home and have access to a windows machine
u_flex
u_flex11mo ago
Ok, thank you
.seally
.seally11mo ago
The GA4 tutorial itself seems to have some bugs (and in fact there are two bug reports open on that repo regarding this matter). These modifications should be done on <root>/src/index.ts file. The viewPath is constructed from __dirname using new URL(".", import.meta.url).pathname. However, on Windows this produces something like "/D:/devel/ga4-tutorials/src/". That /D: doesn't look like a valid path. File Explorer doesn't accept it and opens it in a browser, which proceeds to complain that the path doesn't exist. A look at Node's issue tracker (https://github.com/nodejs/node/issues/23026) suggests this behavior is in accordance with the spec. The correct way to actually convert this seems to be change that line to const __dirname = dirname(fromFileUrl(import.meta.url)) (import those functions from Deno std), though I haven't checked if it's still correct on a Unix-based system yet. It's not over yet. Later, there's this line:
file = await Deno.open(__dirname + "public" + filepath, {
read: true,
});
file = await Deno.open(__dirname + "public" + filepath, {
read: true,
});
The new __dirname we've constructed does not have an ending slash. This should actually call join() (again, from Deno std) instead of doing string concatenation. Adding the slash yourself ("/public") seems to also work. Maybe. I actually would go ahead and change the initialization of viewPath to use join() instead of string interpolation as well just to be safe, but at the moment it doesn't seem to cause any issues. Looks like there are similar issues in the index.ts under the tutorials/ folder as well.
u_flex
u_flex11mo ago
Thanks for the answer, I've tried all your suggestions and solution from the bug report on that repo but still getting error message