Skip to content

[feat] inline script metadata #68007

Backlog
Backlog

Description

@loynoir

What is the problem this feature will solve?

brief

  • python + uv already support inline script metadata

  • nightly rust + cargo already support inline script metadata

inline script metadata

  • hide package management internals
  • hide build process internals
  • keep cwd clean

search keyword

  • node_modules
  • package.json
  • Inline script metadata
  • cargo script

python

https://peps.python.org/pep-0723/#example

https://packaging.python.org/en/latest/specifications/inline-script-metadata/#inline-script-metadata

https://docs.astral.sh/uv/guides/scripts/#declaring-script-dependencies

# /// script
# dependencies = [
#   "requests<3",
#   "rich",
# ]
# ///

import requests
from rich.pretty import pprint

resp = requests.get("https://peps.python.org/api/peps.json")
data = resp.json()
pprint([(k, v["title"]) for k, v in data.items()][:10])

reproduce

$ cd $(mktemp -d)
$ # save as ./x.py
$ uv run ./x.py && echo OK
Installed ... packages in ...ms
[
│   ...
]
OK

Keeps the CWD clean.

$ ls -A
x.py

rust

https://goals.rust-lang.org/2026/highlights.html#running-rust-scripts-will-get-more-convenient-with-cargo-script

https://rust-lang.github.io/rfcs/3424-cargo-script.html

https://rust-lang.github.io/rfcs/3424-cargo-script.html#adding-a-dependency

$ cargo update --manifest-path hello_world.rs

reproduce

#!/usr/bin/env -S cargo +nightly -Zscript
---cargo
[package]
edition = "2024"

[dependencies]
clap = { version = "4.2", features = ["derive"] }
---

use clap::Parser;

#[derive(Parser, Debug)]
#[clap(version)]
struct Args {
    #[clap(short, long, help = "Path to config")]
    config: Option<std::path::PathBuf>,
}

fn main() {
    let args = Args::parse();
    println!("{:?}", args);
}
$ cd $(mktemp -d)
$ # save as ./x.rs
$ cargo +nightly -Zscript ./x.rs --config value && echo OK
    Updating crates.io index
     Locking {{number}} packages to highest Rust {{version}}-nightly compatible versions
  Downloaded {{pkg}} v{{semver}}
  ...
  Downloaded {{number}} crates ({{number}}KiB) in {{number}}s
   Compiling {{pkg}} v{{semver}}
   ...
   Compiling x v0.0.0 (/tmp/tmp.xxx/x.rs)
    Finished `dev` profile [unoptimized + partial debuginfo] target(s) in {{number}}s
     Running `/home/xxx/.cargo/build/xxx/xxx/target/debug/x`
Args { config: Some("value") }
OK

Keeps the CWD clean.

$ ls -A
x.rs

What is the feature you are proposing to solve the problem?

also support inline script metadata

What alternatives have you considered?

No response

Related

#68007

https://github.com/orgs/pnpm/discussions/18689

Activity

  1. added
    feature request
    on Dec 4, 2026
  2. changed the title [-][feat] inline metadata script[/-] [+][feat] inline script metadata[/+] on Dec 4, 2026
  3. Renegade334 commented on Dec 4, 2026

    @Renegade334
    Member

    For context, this is effectively the same proposal as the stale #64809.

    hide package management internals

    Bear in mind that the Node.js runtime does not perform package management.

  4. loynoir commented on Dec 4, 2026

    @loynoir
    Author

    I think at least two languages and their package managers have adopted this. This prior art can therefore be considered mature, so it would be nice to see it happen in the Node.js ecosystem as well.

  5. loynoir commented on Dec 4, 2026

    @loynoir
    Author

    And

    • pep-0723 inline-script-metadata stated on the Python official website.
    • cargo script stated on the Rust official website.

    Thus, I open FR in Node.js repo first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions