D
Deno

help

Deno cannot import mainfile by reading from package.json

RHRen Hiyama9/22/2023
deno 1.36.0 (release, x86_64-unknown-linux-gnu) v8 11.6.189.12 typescript 5.1.6
No description
RHRen Hiyama9/22/2023
TypeError: Directory import /home/ren/coding/frontend/node_modules/@reejs/imports is not supported resolving import from file:///home/ren/coding/frontend/.reejs/serve/6a3aba.js
Did you mean to import index.js within the directory?
Caused by:
Is a directory (os error 21)
at async file:///home/ren/coding/frontend/node_modules/.deno/reejs@0.13.4/node_modules/reejs/src/cli/cmds/packit.js:408:30 {
code: "ERR_MODULE_NOT_FOUND"
}
TypeError: Directory import /home/ren/coding/frontend/node_modules/@reejs/imports is not supported resolving import from file:///home/ren/coding/frontend/.reejs/serve/6a3aba.js
Did you mean to import index.js within the directory?
Caused by:
Is a directory (os error 21)
at async file:///home/ren/coding/frontend/node_modules/.deno/reejs@0.13.4/node_modules/reejs/src/cli/cmds/packit.js:408:30 {
code: "ERR_MODULE_NOT_FOUND"
}
this problem doesnt exist on nodejs though. package.json has "main" field which says index.js is the main file. and index.js file exists.
DAHDeno AI Helper9/22/2023
According to the documentation, Deno does support resolving dependencies based on a package.json file in the current or ancestor directories. This is similar to how Node.js resolves dependencies. However, we recommend using import maps with deno.json. Here's an example of how you can use a package.json file with Deno:
{
"name": "@deno/my-example-project",
"description": "An example app created with Deno",
"type": "module",
"scripts": {
"dev": "deno run --allow-env --allow-sys main.ts"
},
"dependencies": {
"chalk": "^5.2"
}
}
{
"name": "@deno/my-example-project",
"description": "An example app created with Deno",
"type": "module",
"scripts": {
"dev": "deno run --allow-env --allow-sys main.ts"
},
"dependencies": {
"chalk": "^5.2"
}
}
And the corresponding main.ts file:
import chalk from "chalk";

console.log(chalk.green("Hello from Deno!"));
import chalk from "chalk";

console.log(chalk.green("Hello from Deno!"));
You can run this script with the following command:
deno run --allow-env --allow-sys main.ts
deno run --allow-env --allow-sys main.ts
Or execute package.json scripts via deno task:
deno task dev
deno task dev
Please note that importing via a bare specifier (ex. import { readFileSync } from "fs";) without an import map is not supported. If you attempt to do so and the bare specifier matches a Node.js built-in module not found in an import map, Deno will provide a helpful error message asking if you meant to import with the node: prefix. 🦕
RHRen Hiyama9/22/2023
I'm using node compat to do the job, is that not possible?
Mmarvinh.9/22/2023
@renhiyama.gg does the error occur in latest deno too? iirc there were a couple of fixes in there regarding npm support
RHRen Hiyama9/22/2023
nixos still didnt update deno to 1.37.0 ... lemme quickly try it in ubuntu
RHRen Hiyama9/22/2023
tried docker image, it is more buggy there, any wierd reasons? sudo docker run -it --init -p 3000:3000 -v $PWD:/app denoland/deno:alpine-1.37.0 run -A npm:reejs@0.13.4 -v incase u are interested
No description
Mmarvinh.9/22/2023
that sounds like process.env isn't populated
RHRen Hiyama9/22/2023
maybe, cant read that code so cant confirm really. but 1.36.0 works fine (except the issue im currently having)
Mmarvinh.9/22/2023
maybe best to file an issue in the deno tracker. Sounds like something is wrong here

Looking for more? Join the community!

Recommended Posts
Deno LSP in a Web WorkerHas anyone come across the lsp running in a web worker? I have an online editor (Monaco) that peopleHow do you get a Deno Jupyter notebook to recognize Deno and other types in vscode?See attached screenshotModule not found when running deno runSomething weird has started happening. When I run `deno run src/main.ts` it seems as if Deno is tryesm_entry_point / extension macro; ReferenceErrorHow do I use esm_entry_point properly? I defined my extension as: ```rust extension!( ext_name,remoteAddr returning localhost on Deno DeployI saw this thread (https://discord.com/channels/684898665143206084/1055631150787334184) about gettinDeno-native Nuxt.js?The recent [The State of Web Frameworks on Deno](https://deno.com/blog/web-frameworks-on-deno) blogDeno support Fleet IDE?Hello, can the deno plug-in be used on the Fleet editor of JetBrains IDEs? Thank you.Async execution contextIs there any way I can create a global that is unique to an async operation? I would like to use thaError Deploying to Deno Deploy LODASH isEmpty.jsI am having issues deploying to deno deploy. All was well 3 days ago. Made some changes today - but need to refersh page for message each time a user from different country sends a messageHey I was going through the below deno chat app and found a bug which is the need to referesh the paAPI architecture for generic callbackHi there, I have a general question about code architecture for an API I'm doing. Basically, it listHow can I run `deno test` on all `*.spec.ts` files contains in a specific directory ?Everything is in the question, it seems very strange that we do not have a `pattern` option to speciuseEffect in the islandsSeeing a strange error in the browser window as soon as I add a simple as ```ts useEffect(() => { Basic react server side rendering does not work on Deno Deploy but does locallyThe below application work correctly locally but fails on Deno Deploy. On Deno Deploy, all my responode cryptoHey everyone, can you explain why certain packages such as node/crypto are not included in newer verPretty new to Deno, what is the recommended way to create a monorepo-like in Deno ?Everything is in the question. I tried during the entire week-end to get up & running with monorepo-[fresh] injecting css into head in a componentWhen I inject css in the head of my html in a component, it works perfectly, but when I reuse the coAutosave firing on editing `.ts` files when a separate Deno enabled project is openHello, I am working on slack automation using deno. I'm developing with webstorm, but I'm having a pProblem with parsing `base64url` from a `Buffer (node)`help , it works in bun but not in Deno, I don't know if is a bug from them or it's not implemented hUUID of managed KV databaseHello, I am trying to follow [this doc](https://docs.deno.com/kv/manual/on_deploy#connect-to-managed