277 karma · joined Sep 3, 2018 (8y ago) · 60 submissions
comment 5mo ago · link · parent
``` function checkNodeVersion(nodeVersion) { const major = parseInt(nodeVersion.split(".")[0], 10); const minor = parseInt(nodeVersion.split(".")[1], 10); return (major === 20 && minor >= 19) || (major === 22 && minor >= 12) || major > 22; } if (!checkNodeVersion(process.versions.node)) console.warn(`You are using Node.js ${process.versions.node}. Vite requires Node.js version 20.19+ or 22.12+. Please upgrade your Node.js version.`); ```
And that error should be thrown only in Deno < 2.2 which presented `process.version` as `20.11.1`.
Are you 100% sure this is not running some old version of Deno on your system?
comment 5mo ago · link · parent
comment 5mo ago · link · parent
Disclaimer: I'm the author of the linked PR. Using AI here is not really at fault here - it was just a giant rewrite that replaced how we do `node:http` in Deno. Replacing the engine while driving is never easy and we did the best we could. While we have a lot of test coverage and we use tests directly from Node.js codebase, we just don't catch everything. We're constantly working on improving the situation and I'm sorry you hit a problem. I can assure you that we are fixing all Node compat bugs as quickly as possible.
comment 5mo ago · link · parent
comment 6mo ago · link · parent
> The worst of the changes is "lib.node included by default", if I'm writing Deno or web code I absolutely don't want node types included by default.
Since a few versions ago, Deno now has some of Node.js APIs included by default (eg. process or Buffer). It's really more of a bug fix to make type-checking work properly.
While it's not ideal, you can still decide which types you want included by default with `compilerOptions.types`. `["deno.ns", "web"]` should give you what you're looking for.
comment 6mo ago · link · parent
comment 6mo ago · link · parent
comment 3y ago · link · parent
comment 3y ago · link · parent
Eg. if you have a Vite app (or any other app really) with "package.json" and some "scripts" defined there, just try running "deno task <script_name>". Deno will automatically pick up "package.json" and try its best to run the that script.
It's not fully done, but in our testing we got a lot of non-trivial projects running that way. If something doesn't work in your case, I would greatly appreciate a bug report to help us fix this.
As for the written guide - there's not a single one at the moment - it's something we'll be looking into in the coming months.
comment 3y ago · link · parent
comment 3y ago · link · parent
> for one the security model is incompatible with node APIs.
All Node.js APIs are polyfilled using Deno APIs and as such these Node.js API are subject to the same permission model as regular Deno programs.
> however if deno were to support all npm packages, it would necessarily basically have to implement the entire node api, including support for pre async/await (aka callbacks)
We're not aiming for 100% compatibility, though we managed to polyfill a hefty amount of built-in Node modules, including ones that are callback based.
> consider just the c++ embedder apis. how exactly would deno deal with that with respect to permissions?
This is the same situation as with Deno's FFI API. You need to pass `--allow-ffi` flag to enable usage of `Deno.dlopen` (or `require("./foo.node")` for N-API extensions). That said when you load dynamic libraries all bets are off - we can't control what the dynamic library can do and you effectively open up your whole system. Still, you can't load such libraries unless `--allow-ffi` flag is passed.
Hope this clears up some things.
comment 3y ago · link · parent
We're debating how to best tackle that. If you have a specific use case in mind I would appreciate opening a feature request in our issue tracker.
comment 3y ago · link · parent
[0] https://doc.rust-lang.org/book/ [1] https://www.youtube.com/watch?v=8aGhZQkoFbQ
comment 3y ago · link · parent
Just yesterday we posted a second part of this post [0] where we add "fetch"-like API and TypeScript transpilation.
Happy to answer your questions.
[0] https://deno.com/blog/roll-your-own-javascript-runtime-pt2
comment 4y ago · link · parent
The development is well under way, we expect to ship first iteration of this feature in the next release (v1.25) in the coming weeks.