Fresh 2 new project breaks
Following the instructions on the Fresh 2 announcement: https://deno.com/blog/an-update-on-fresh
deno run -Ar jsr:@fresh/[email protected]
when i run deno task start as instructed it breaks:
❯ tmp cd fresh-project
❯ fresh-project deno task start
Warning The following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed:
┠─ npm:[email protected]
┃
┠─ This may cause the packages to not work correctly.
┠─ Lifecycle scripts are only supported when using a `node_modules` directory.
┠─ Enable it in your deno config file:
┖─ "nodeModulesDir": "auto"
Task start deno run -A main.ts
error: Uncaught (in promise) Error: Found 1 islands, but did not find build snapshot at:
/Users/karl/tmp/fresh-project/_fresh/snapshot.json.
Maybe your forgot to run deno task build before starting the production server
or maybe you wanted to run deno task dev to spin up a development server instead?
throw new Error(
^
at ProdBuildCache.fromSnapshot (https://jsr.io/@fresh/core/2.0.0-alpha.34/src/build_cache.ts:67:17)
at App.handler (https://jsr.io/@fresh/core/2.0.0-alpha.34/src/app.ts:251:41)
at App.listen (https://jsr.io/@fresh/core/2.0.0-alpha.34/src/app.ts:332:32)
at file:///Users/karl/tmp/fresh-project/main.ts:29:13
❯ fresh-project
❯ fresh-project deno --version
deno 2.3.1 (stable, release, aarch64-apple-darwin)
v8 13.5.212.10-rusty
typescript 5.8.3
❯
Following the instructions on the Fresh 2 announcement: https://deno.com/blog/an-update-on-fresh
deno run -Ar jsr:@fresh/[email protected]when i run
deno task startas instructed it breaks:❯ tmp cd fresh-project ❯ fresh-project deno task start Warning The following packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed: ┠─ npm:[email protected] ┃ ┠─ This may cause the packages to not work correctly. ┠─ Lifecycle scripts are only supported when using a `node_modules` directory. ┠─ Enable it in your deno config file: ┖─ "nodeModulesDir": "auto" Task start deno run -A main.ts error: Uncaught (in promise) Error: Found 1 islands, but did not find build snapshot at: /Users/karl/tmp/fresh-project/_fresh/snapshot.json. Maybe your forgot to run deno task build before starting the production server or maybe you wanted to run deno task dev to spin up a development server instead? throw new Error( ^ at ProdBuildCache.fromSnapshot (https://jsr.io/@fresh/core/2.0.0-alpha.34/src/build_cache.ts:67:17) at App.handler (https://jsr.io/@fresh/core/2.0.0-alpha.34/src/app.ts:251:41) at App.listen (https://jsr.io/@fresh/core/2.0.0-alpha.34/src/app.ts:332:32) at file:///Users/karl/tmp/fresh-project/main.ts:29:13 ❯ fresh-project❯ fresh-project deno --version deno 2.3.1 (stable, release, aarch64-apple-darwin) v8 13.5.212.10-rusty typescript 5.8.3 ❯
The information on the freshv2 blog is incomplete in some parts. For example, after using the upgrade script, you should not directly use "deno task start", which is a change compared to freshv1. You need to execute "deno task build" first, and then "deno task start" for the production - environment. Of course, you can also directly execute "deno task dev" alone for the development environment.
Meanwhile, you may need to clear the relevant cache to solve potential cache problems. Another problem is that "NodeModules: true" exists in freshv1, but it does not exist in the init of Freshv2. Personally, I suggest adjusting it to "auto", which should be able to handle the relevant Npm issues well.
Thanks @SisyphusZheng deno task build worked, and so did deno task dev.
For reference, https://github.com/denoland/fresh/commit/1e6f0d69b1248d324e9fdd527b4df0c52c49c6f5 is already on main and adjusts the message accordingly.