denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98.07k stars 5.4k forks source link

Error: Cannot find package.json #26794

Open quadratz opened 2 weeks ago

quadratz commented 2 weeks ago

I’m not sure if this is the right repo for this issue, so my apologies if it’s actually related to the Astro or vitefu package instead of Deno. Please let me know, and I’ll open the issue in the correct repository. Thank you.

Folder structure:

.
├─ deno.json
└─ src/
   └─ pages/
      └─ index.astro

deno.json:

{
  "lock": false,
  "nodeModulesDir": "auto",
  "tasks": {
    "setup": "deno install && astro sync --verbose"
  },
  "imports": {
    "@astrojs/check": "npm:@astrojs/check@0.9.4",
    "astro": "npm:astro@5.0.0-beta.7",
    "typescript": "npm:typescript@5.6.3"
  }
}

Cmd:

deno task setup

Output:

Cannot find package.json from /tmp/deno-bug/
  Location:
    /tmp/deno-bug/node_modules/.deno/vitefu@1.0.3/node_modules/vitefu/src/index.js:33:13
  Stack trace:
    at crawlFrameworkPkgs (file:///tmp/deno-bug/node_modules/.deno/vitefu@1.0.3/node_modules/vitefu/src/index.js:33:13)
    at async syncContentCollections (file:///tmp/deno-bug/node_modules/.deno/astro@5.0.0-beta.7/node_modules/astro/dist/core/sync/index.js:144:5)
    at async sync (file:///tmp/deno-bug/node_modules/.deno/astro@5.0.0-beta.7/node_modules/astro/dist/core/sync/index.js:48:10)
    at async runCommand (file:///tmp/deno-bug/node_modules/.deno/astro@5.0.0-beta.7/node_modules/astro/dist/cli/index.js:104:7)

Version: deno 2.0.5+73fbd61 (canary, release, x86_64-unknown-linux-gnu) v8 12.9.202.13-rusty typescript 5.6.2

KnorpelSenf commented 2 weeks ago

I think I ran into the same issue. In your case astro is not actually run by Deno. It is specific to Node that the .bin directory of the node_modules gets added to the path inside npm run scripts.

With Deno, you need to type out deno -A npm:astro if you want to run the package that you installed. Otherwise, it will run the globally installed CLI astro. (Edit: I am actually not entirely sure if this is correct.)