denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.42k stars 640 forks source link

Cannot find module 'preact' or its corresponding type declarations #364

Closed andrewasd closed 2 years ago

andrewasd commented 2 years ago

Hi, im trying to run the code in this page after following all the docs but i don't know how to install the preact module https://fresh.deno.dev/docs/getting-started/create-a-route image

xstevenyung commented 2 years ago

The Preact module should import automatically when starting the project with deno task start.

Deno automatically cache all dependencies so there is no "installation" to do.

I think you are just missing some VSCode settings (I'm assuming from the screenshot that this is VSCode):

  1. Make sure to install the Deno VSCode extension
  2. Enable the Deno extension in your VSCode settings or by creating a .vscode/settings.json file with:
    {
    "deno.enable": true
    }
  3. Restart VSCode to make sure the settings are loaded correctly
fdemir commented 2 years ago

These instructions should be added to the documentation. So many people have issues like that.

lucacasonato commented 2 years ago

The required VS Code files are now added in the init script.

nhasdarjian commented 2 years ago

I was still having this problem, but it resolved when I loaded the project folder itself in VSCode and not a parent folder. Just a tip for anyone else who might still get this error.

teneburu commented 1 month ago

I have the same problem along with other errors like 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. I just completed the new project script from fresh and i have not modified anything.

I'm using VSCodium last version. The extension is installed and I can see Deno Language Server in Output picking up the configuration file.

In .vscode/settings.json

{ "deno.enable": true, "deno.lint": true, "editor.defaultFormatter": "denoland.vscode-deno", "[typescriptreact]": { "editor.defaultFormatter": "denoland.vscode-deno" }, "[typescript]": { "editor.defaultFormatter": "denoland.vscode-deno" }, "[javascriptreact]": { "editor.defaultFormatter": "denoland.vscode-deno" }, "[javascript]": { "editor.defaultFormatter": "denoland.vscode-deno" }, "css.customData": [ ".vscode/tailwind.json" ] } The selected language is typescriptreact. I expected it to work after restart but it does not.

qw