Movatterモバイル変換


[0]ホーム

URL:


DocsGuidesBlog
Discord logoDiscord logo
Discord
GitHub logoGitHub logo

Intro

What is Bun?

Installation

Quickstart

TypeScript

Templating

bun init

bun create

Runtime

bun run

File types

TypeScript

JSX

Environment variables

Bun APIs

Web APIs

Node.js compatibility

Single-file executable

Plugins

Watch mode

Module resolution

Auto-install

bunfig.toml

Debugger

Framework APISOON

Package manager

bun install

bun add

bun remove

bun update

bun publish

bun outdated

bun link

bun pm

Global cache

Workspaces

Lifecycle scripts

Filter

Lockfile

Scopes and registries

Overrides and resolutions

Patch dependencies

.npmrc support

Bundler

Bun.build

HTML & static sites

CSS

Fullstack Dev Server

Hot reloading

Loaders

Plugins

Macros

vs esbuild

Test runner

bun test

Writing tests

Watch mode

Lifecycle hooks

Mocks

Snapshots

Dates and times

DOM testing

Code coverage

Package runner

bunx

API

HTTP server

HTTP client

WebSockets

Workers

Binary data

Streams

SQL

S3 Object Storage

File I/O

import.meta

SQLite

FileSystemRouter

TCP sockets

UDP sockets

Globals

$ Shell

Child processes

HTMLRewriter

Hashing

Console

Cookie

FFI

C Compiler

Testing

Utils

Node-API

Glob

DNS

Semver

Color

Transpiler

Project

Roadmap

Benchmarking

Contributing

Building Windows

Bindgen

License

Bun logoBunBun

Search the docs...

/

Intro

What is Bun?

Installation

Quickstart

TypeScript

Templating

bun init

bun create

Runtime

bun run

File types

TypeScript

JSX

Environment variables

Bun APIs

Web APIs

Node.js compatibility

Single-file executable

Plugins

Watch mode

Module resolution

Auto-install

bunfig.toml

Debugger

Framework APISOON

Package manager

bun install

bun add

bun remove

bun update

bun publish

bun outdated

bun link

bun pm

Global cache

Workspaces

Lifecycle scripts

Filter

Lockfile

Scopes and registries

Overrides and resolutions

Patch dependencies

.npmrc support

Bundler

Bun.build

HTML & static sites

CSS

Fullstack Dev Server

Hot reloading

Loaders

Plugins

Macros

vs esbuild

Test runner

bun test

Writing tests

Watch mode

Lifecycle hooks

Mocks

Snapshots

Dates and times

DOM testing

Code coverage

Package runner

bunx

API

HTTP server

HTTP client

WebSockets

Workers

Binary data

Streams

SQL

S3 Object Storage

File I/O

import.meta

SQLite

FileSystemRouter

TCP sockets

UDP sockets

Globals

$ Shell

Child processes

HTMLRewriter

Hashing

Console

Cookie

FFI

C Compiler

Testing

Utils

Node-API

Glob

DNS

Semver

Color

Transpiler

Project

Roadmap

Benchmarking

Contributing

Building Windows

Bindgen

License

import.meta

GitHub logoGitHub logo

Edit on GitHub

Theimport.meta object is a way for a module to access information about itself. It's part of the JavaScript language, but its contents are not standardized. Each "host" (browser, runtime, etc) is free to implement any properties it wishes on theimport.meta object.

Bun implements the following properties.

/path/to/project/file.ts
import.meta.dir;// => "/path/to/project"import.meta.file;// => "file.ts"import.meta.path;// => "/path/to/project/file.ts"import.meta.url;// => "file:///path/to/project/file.ts"import.meta.main;// `true` if this file is directly executed by `bun run`// `false` otherwiseimport.meta.resolve("zod");// => "file:///path/to/project/node_modules/zod/index.js"
import.meta.dirAbsolute path to the directory containing the current file, e.g./path/to/project. Equivalent to__dirname in CommonJS modules (and Node.js)
import.meta.dirnameAn alias toimport.meta.dir, for Node.js compatibility
import.meta.envAn alias toprocess.env.
import.meta.fileThe name of the current file, e.g.index.tsx
import.meta.pathAbsolute path to the current file, e.g./path/to/project/index.ts. Equivalent to__filename in CommonJS modules (and Node.js)
import.meta.filenameAn alias toimport.meta.path, for Node.js compatibility
import.meta.mainIndicates whether the current file is the entrypoint to the currentbun process. Is the file being directly executed bybun run or is it being imported?

import.meta.resolve

Resolve a module specifier (e.g."zod" or"./file.tsx") to a url. Equivalent toimport.meta.resolve in browsers

import.meta.resolve("zod");// => "file:///path/to/project/node_modules/zod/index.ts"
import.meta.urlAstring url to the current file, e.g.file:///path/to/project/index.ts. Equivalent toimport.meta.url in browsers

Previous

File I/O

Next

SQLite

GitHub logoGitHub logo

Edit on GitHub


[8]ページ先頭

©2009-2025 Movatter.jp