krml
krml5mo ago

Fresh project next to regular Deno project

Hey, I have a question about adding a fresh project next to a regular Deno project. I have the following setup, with the global deno.json sitting in the root directory
- .vscode
- settings.json
- gui
- fresh-resources-here
- worker
- backend code
- orchestrator
- backend code
deno.json
- .vscode
- settings.json
- gui
- fresh-resources-here
- worker
- backend code
- orchestrator
- backend code
deno.json
Before the introduction of the gui directory, any import and the Deno namespace works fine. Using enablePath without the gui directory also works fine, but adding gui to the paths breaks it. Giving me the Deno.cron not found in the Deno namespace. It seems that the global settings.json where we define deno.unstable: true does not work after introducing the gui directory and breaking the whole Deno namespace for us. Maybe I just have a problem understanding it, but I cannot get it to work in VSCode without problems.
4 Replies
Deno AI Helper
Deno AI Helper5mo ago
Based on the documentation, when working with a Visual Studio Code workspace that contains both Deno and non-Deno parts, such as your project with a Fresh web framework (gui directory) and regular Deno code (worker and orchestrator directories), you can use the deno.enablePaths setting to specify which directories should be treated as Deno-enabled. The deno.enablePaths setting allows you to selectively enable Deno for certain sub-paths within your workspace, while other parts of your codebase will not be treated as Deno projects and will use the built-in JavaScript/TypeScript language server provided by VSCode. Here's a step-by-step approach to troubleshoot the issue you're facing: 1. Check Workspace Configuration: Ensure that your workspace configuration in .vscode/settings.json is correctly set up to enable Deno for the specific paths you want. For example, if you want to enable Deno only for the worker and orchestrator directories, your settings might look like this:
{
"deno.enable": true,
"deno.unstable": true,
"deno.enablePaths": ["./worker", "./orchestrator"]
}
{
"deno.enable": true,
"deno.unstable": true,
"deno.enablePaths": ["./worker", "./orchestrator"]
}
2. Verify Deno Extension Settings: Make sure that the Deno extension is properly configured in VSCode to recognize the deno.json configuration file. The extension should automatically activate when it detects a deno.json file in your project. 3. Check for Conflicts: If you have any other extensions or settings that might conflict with the Deno extension, try disabling them to see if that resolves the issue. 4. Deno Namespace and Unstable Features: Since you're using Deno.cron, which is an unstable API, you need to ensure that the deno.unstable setting is enabled. This should be set in the workspace settings where Deno is enabled. 5.
Deno AI Helper
Deno AI Helper5mo ago
Restart VSCode: Sometimes, changes to the settings may require a restart of VSCode to take effect. Close and reopen VSCode to ensure that all settings are reloaded. 6. Check Deno Version: Ensure that you are using a version of Deno that supports the features you're trying to use. The Deno.cron API, being unstable, may not be available in older versions of Deno. 7. Use Deno: Language Server Status: You can use the Deno: Language Server Status command from the command palette in VSCode to check what the Deno language server thinks is your current active configuration. This can help you verify that the settings are being applied as expected. If after following these steps you still encounter issues, it might be helpful to look at the specific error messages and diagnostics provided by the Deno language server in VSCode. These messages can give you more insight into what might be going wrong with the configuration or the
krml
krml5mo ago
Thats pretty much everything I already did
krml
krml5mo ago
To whoever will find this. The solution is setting // <reference lib="deno.unstable" />in the main.ts file of Fresh. The reason for that is, that Fresh sets /// <reference no-default-lib="true" /> which seems to remove the Deno global (https://github.com/denoland/deno/issues/20420). This comment helped me a lot: https://github.com/denoland/deno/issues/20248#issuecomment-1689881374
GitHub
Issues · denoland/deno
A modern runtime for JavaScript and TypeScript. Contribute to denoland/deno development by creating an account on GitHub.
GitHub
bug?: deno check need --unstable flags but already include · Iss...
Description When i using fresh from project template and i run deno task start will got error need --unstable flags, but i already include In Deno json { "tasks"{ "check": "...