Skip to content

Update Deno pkgs regularly #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jduan00 opened this issue Apr 23, 2025 · 2 comments
Open

Update Deno pkgs regularly #90

jduan00 opened this issue Apr 23, 2025 · 2 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jduan00
Copy link
Contributor

jduan00 commented Apr 23, 2025

Run this command monthly

deno outdated

cat deno.lock 
@jduan00 jduan00 changed the title Update Deno pkgs Update Deno pkgs regularly Apr 23, 2025
@jduan00 jduan00 added good first issue Good for newcomers enhancement New feature or request labels Apr 23, 2025
@samshdn
Copy link
Contributor

samshdn commented Apr 24, 2025

agree.

Can we set a periodic task in a GitHub project?

@jduan00 jduan00 moved this to In progress in Release v0.1 (Prototype) Apr 24, 2025
@jduan00
Copy link
Contributor Author

jduan00 commented May 23, 2025

Let's revisit to use this format so we can use the latest versions.

Importing a Module Using the Latest Version with deno.json

Adding the Latest Version Automatically

To import a module using the latest version and manage it via your deno.json file, the recommended approach is to use the deno add command. This command fetches the latest version of the specified module and adds it to the imports section of your deno.json file. Here’s how you do it:

deno add jsr:@luca/cases

This command will automatically add the latest version of the @luca/cases module to your deno.json:

{
  "imports": {
    "@luca/cases": "jsr:@luca/cases@^1.0.0"
  }
}

The caret (^) in the version specifier means Deno will use the latest compatible version within the same major version range[1].

Importing in Your Code

After adding the module, you can import it in your TypeScript or JavaScript files using the mapped specifier:

import { camelCase } from "@luca/cases";

This import will resolve using the mapping in your deno.json[1].

Forcing an Update to the Latest Version

If you want to ensure you are always using the latest version (for example, after a new release), you can:

  • Run deno add again for the package, which will update the version in deno.json if a newer one is available[1].
  • Use deno outdated to check for newer versions and deno add or manually update as needed[5].

Summary Table

Step Command/Action Result
Add latest version deno add jsr:@luca/cases Adds latest version to deno.json imports
Import in code import { camelCase } from "@luca/cases" Uses the mapped module from deno.json
Update to latest deno add jsr:@luca/cases (again) Updates to latest version in deno.json if available

Key Points

  • Always use deno add to ensure your deno.json stays in sync with the latest module versions.
  • The imports field in deno.json acts as an import map, making your imports cleaner and easier to manage[1].
  • For third-party modules, prefer using the jsr: or npm: prefixes for better compatibility and versioning[1][2].

This workflow ensures you are always using the latest version of your dependencies in Deno projects.

Sources
[1] Modules and dependencies - Deno Docs https://docs.deno.com/runtime/fundamentals/modules/
[2] Dependency Management in Deno - Kevin Cunningham https://www.kevincunningham.co.uk/posts/intro-to-jsr
[3] Importing JSON - Deno Docs https://docs.deno.com/examples/importing_json/
[4] deno.json and package.json - Deno Docs https://docs.deno.com/runtime/fundamentals/configuration/
[5] How can I force Deno to download latest version of a dependency? https://stackoverflow.com/questions/61444575/how-can-i-force-deno-to-download-latest-version-of-a-dependency
[6] Deno Third Party Modules https://deno.land/x
[7] Module versioning, dependency management, and more - GitHub denoland/deno#4574
[8] Deno 2.1: Wasm Imports and other enhancements https://deno.com/blog/v2.1
[9] Create your first module with Deno - Livio Brunner https://www.brunnerliv.io/articles/create-your-first-module-with-deno/
[10] Confuse about the way import module on Deno project https://stackoverflow.com/questions/78505466/confuse-about-the-way-import-module-on-deno-project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: In progress
Status: No status
Development

No branches or pull requests

2 participants