fresh icon indicating copy to clipboard operation
fresh copied to clipboard

Fresh 2 new project breaks

Open kewp opened this issue 6 months ago • 2 comments

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
❯

kewp avatar May 29 '25 03:05 kewp

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
❯

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.

SisyphusZheng avatar May 30 '25 01:05 SisyphusZheng

Thanks @SisyphusZheng deno task build worked, and so did deno task dev.

kewp avatar May 30 '25 03:05 kewp

For reference, https://github.com/denoland/fresh/commit/1e6f0d69b1248d324e9fdd527b4df0c52c49c6f5 is already on main and adjusts the message accordingly.

isti115 avatar Jun 19 '25 17:06 isti115