How to use vendoring with node_modules

As trying to recreate a DENO_DIR via deno cache creates different results on different machines, I have to assume that the lockfile is not enough. So I wanted to try to vendor instead, so I set "vendor": true in my deno.jsonc and ran a single build, which creates a vendor and a node_modules folder. Even though I copied both, the vendor and node_modules to my git repository, the remote (airgapped) builder fails like this:
Download https://registry.npmjs.org/wrap-ansi
Download https://registry.npmjs.org/wrappy
Download https://registry.npmjs.org/yallist
Download https://registry.npmjs.org/yaml
Download https://registry.npmjs.org/zwitch
error: failed reading lockfile '/build/source/deno.lock'

Caused by:
Error getting response at https://registry.npmjs.org/@alloc/quick-lru for package "@alloc/quick-lru": error sending request for url (https://registry.npmjs.org/@alloc/quick-lru): error trying to connect: dns error: failed to lookup address information: Temporary failure in name resolution: error trying to connect: dns error: failed to lookup address information: Temporary failure in name resolution: dns error: failed to lookup address information: Temporary failure in name resolution: failed to lookup address information: Temporary failure in name resolution
Download https://registry.npmjs.org/wrap-ansi
Download https://registry.npmjs.org/wrappy
Download https://registry.npmjs.org/yallist
Download https://registry.npmjs.org/yaml
Download https://registry.npmjs.org/zwitch
error: failed reading lockfile '/build/source/deno.lock'

Caused by:
Error getting response at https://registry.npmjs.org/@alloc/quick-lru for package "@alloc/quick-lru": error sending request for url (https://registry.npmjs.org/@alloc/quick-lru): error trying to connect: dns error: failed to lookup address information: Temporary failure in name resolution: error trying to connect: dns error: failed to lookup address information: Temporary failure in name resolution: dns error: failed to lookup address information: Temporary failure in name resolution: failed to lookup address information: Temporary failure in name resolution
(there are much of the Download https://registry.npmjs.org/… lines, all refer to npmjs of course)
N
NobbZ43d ago
Also weird, other tools can properly read the lockfile, like cat and jqing just works…
DAH
Deno AI Helper43d ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided, there are a couple of things to note: 1. Deno does not use node_modules by design. The presence of a node_modules folder is not a standard part of Deno's workflow, as Deno uses URLs to manage dependencies. 2. The error message you're seeing suggests that there is a network issue on your remote (airgapped) builder. It seems like it's trying to reach out to the npm registry, which should not be the case if you're using Deno and have vendored all your dependencies correctly. 3. The deno.lock file is meant to ensure that the exact same dependencies are used every time you run deno cache. If the lockfile is not being respected, or if there are network calls being made when you expect everything to be vendored, there might be an issue with how the vendoring was set up. 4. Make sure that when you're copying the vendor directory to your git repository, you're also including the deno.lock file, as it is crucial for ensuring that the correct versions of your dependencies are used. Please note that this advice is not based on the Deno documentation, and you should double-check the accuracy of the advice given. It's also possible that there might be a misunderstanding of how Deno's vendoring works, so I would recommend reviewing the official documentation on dependency management and vendoring in Deno, and ensuring that you're following the recommended practices.
N
NobbZ43d ago
"airgapped" means, without internet, yes. Any failing internet access is by design. And I have ensured by hashing mechanisms, that the vendor as well as the node_modules on the builder are the same as on my machine. After looking closer at the build output, it seems that deno task resolves correctly, and then the actual error happens as part of the resolved task. On the dev host, I also can observe that fetching of dependencies happens "in stages". I first see download progress, then the following lines get printed, then another batch of dependencies is downloaded.
Task build deno task lume
Task lume echo "import 'lume/cli.ts'" | deno run -A -
Task build deno task lume
Task lume echo "import 'lume/cli.ts'" | deno run -A -
It also appears that on the dev host only the second batch of downloads appears to create the node_modules. So the issue might actually be in lume, rather than deno.
L
Leokuma42d ago
I think I've seen an open issue describing problems to cache npm deps. Might be a bug
N
NobbZ42d ago
Can you link the issue? I'd be happy to provide more information or reproducers if possible
L
Leokuma42d ago
Actually it was not an issue. It was question in this channel that I thought might be related: https://discord.com/channels/684898665143206084/1212752847364431923/1212768217798279178 Not sure though
More Posts
Make an image cropper that crops from data uriHow to make an image cropper that crops to the given dimensionsBest practice for releasing a deno package on GitHubIs there a best practice for the release process of a Deno library on GitHub? I use semantic-releasedeno oak : howto force reply immediatly, and process the request later ?Bonjour, My server needs to reply an ACK (200 OK) for each request. If it did not, the client dies. Rust: Unable to bootstrap MainWorkerMy message was too long, moved it to a GitHub discussion: https://github.com/denoland/deno/discussioTailwindCSS: Class-Strings build with variablesSince TailwindCSS does not support classes with variables (like I used before with twind), how wouldImport path autocomplete doesn't workHi 👋 It behaves like it's just a string and not an import path. I have the latest version of Deno aDeno: How to import npm scoped packages with @ in deno?I am trying to import @whiskeysockets/baileys in deno like this: import * as a from "npm:@whiskeysoTo avoide tariling slash in URL on deno deployWe have used deno deploy to build website done using Astro frame work (Astrowind Theme)in productioImporting internal modulesI would like to use https://github.com/denoland/deno/blob/main/ext/console/01_console.js in my code,Strange error after lint in github actionsfor a some reason after: ```yml - name: Run linter run: deno lint ``` I get error that saysHow to encrypt and decrypt files from S3 without loading the hole content into memory?How to encrypt and decrypt files from S3 without loading the hole content into memory? I have this Worksapces / Monorepo supportDeno does not currently have the capability to resolve `workspace:^` references and this breaks any Deno Oak : Can't connect to SSE with Deno DeployHello, I'm trying to deploy an app who use Server Sent Events. The goal is to keep in memory differeError connecting to mongoose when using deno cli**deno-x86_64-pc-windows-msvc v1.41.1** Testing the following code using `nodejs` and on `deno deplHow to debug deno on Visual Studio? (Not VSCode)Is it possible to debug deno on Visual Studio? (not vscode) I only know how to debug it using windoHow to polyfill node imports when bundling with the deno version of esbuild?Hello, I am trying to run esbuild using https://deno.land/x/esbuild to bundle a Deno project into a