Deno
公式: Deno, the next-generation JavaScript runtime
Deno は、V8 JavaScriptエンジン及びRustプログラミング言語に基づいた、JavaScript及びTypeScriptのランタイム環境である。
Node.js の作者であるライアン・ダールによって作成され、セキュリティと生産性に焦点を当てている。
ライアン・ダールが 2018 年に行った講演「Node.jsに関する10の反省点」で発表された。
Deno は単一の実行ファイル内でランタイム環境とパッケージ管理システムの両方の役割を明示的に引き受けるので、別途パッケージ管理システムを必要としない。
Deno - Wikiwand より
インストール
公式: Getting Started - Deno Docs
$ curl -fsSL https://deno.land/install.sh | sh
######################################################################## 100.0% Archive: /home/tomoyan/.deno/bin/deno.zip inflating: /home/tomoyan/.deno/bin/deno Deno was installed successfully to /home/tomoyan/.deno/bin/deno Edit shell configs to add deno to the PATH? (Y/n) -> Enter info: backing '/home/tomoyan/.profile' up to '/home/tomoyan/.deno/.shellRcBackups/.profile.bak' info: backing '/home/tomoyan/.bash_profile' up to '/home/tomoyan/.deno/.shellRcBackups/.bash_profile.bak' info: backing '/home/tomoyan/.bashrc' up to '/home/tomoyan/.deno/.shellRcBackups/.bashrc.bak' info: backing '/home/tomoyan/.zshrc' up to '/home/tomoyan/.deno/.shellRcBackups/.zshrc.bak' Deno was added to the PATH. You may need to restart your shell for it to become available. Set up completions? -> Use space to select and enter to continue > [x] bash [x] zsh Run 'deno --help' to get started Stuck? Join our Discord https://discord.gg/deno
シェルの設定を反映 (zsh)🤔
$ . ~/.zshrc
動作確認🤔
$ deno -v
deno 2.2.3
$ deno -h
Deno: A modern JavaScript and TypeScript runtime Usage: deno [OPTIONS] [COMMAND] Commands: Execution: run Run a JavaScript or TypeScript program, or a task deno run main.ts | deno run --allow-net=google.com main.ts | deno main.ts serve Run a server deno serve main.ts task Run a task defined in the configuration file deno task dev repl Start an interactive Read-Eval-Print Loop (REPL) for Deno eval Evaluate a script from the command line Dependency management: add Add dependencies deno add jsr:@std/assert | deno add npm:express install Installs dependencies either in the local project or globally to a bin directory uninstall Uninstalls a dependency or an executable script in the installation root's bin directory outdated Find and update outdated dependencies remove Remove dependencies from the configuration file Tooling: bench Run benchmarks deno bench bench.ts check Type-check the dependencies clean Remove the cache directory compile Compile the script into a self contained executable deno compile main.ts | deno compile --target=x86_64-unknown-linux-gnu coverage Print coverage reports doc Generate and show documentation for a module or built-ins deno doc | deno doc --json | deno doc --html mod.ts fmt Format source files deno fmt | deno fmt main.ts info Show info about cache or info related to source file jupyter Deno kernel for Jupyter notebooks lint Lint source files init Initialize a new project test Run tests deno test | deno test test.ts publish Publish the current working directory's package or workspace upgrade Upgrade deno executable to given version deno upgrade | deno upgrade 1.45.0 | deno upgrade canary Environment variables: Docs: https://docs.deno.com/go/env-vars DENO_AUTH_TOKENS A semi-colon separated list of bearer tokens and hostnames to use when fetching remote modules from private repositories (e.g. "abcde12345@deno.land;54321edcba@github.com") DENO_CERT Load certificate authorities from PEM encoded file DENO_DIR Set the cache directory DENO_INSTALL_ROOT Set deno install's output directory (defaults to $HOME/.deno/bin) DENO_NO_PACKAGE_JSON Disables auto-resolution of package.json DENO_NO_UPDATE_CHECK Set to disable checking if a newer Deno version is available DENO_TLS_CA_STORE Comma-separated list of order dependent certificate stores. DENO_TRACE_PERMISSIONS Environmental variable to enable stack traces in permission prompts. Possible values: "system", "mozilla". (defaults to "mozilla") HTTP_PROXY Proxy address for HTTP requests (module downloads, fetch) HTTPS_PROXY Proxy address for HTTPS requests (module downloads, fetch) NO_COLOR Set to disable color NO_PROXY Comma-separated list of hosts which do not use a proxy (module downloads, fetch) NPM_CONFIG_REGISTRY URL to use for the npm registry. Docs: https://docs.deno.com Standard Library: https://jsr.io/@std Bugs: https://github.com/denoland/deno/issues Discord: https://discord.gg/deno
Deno kernel for Jupyter notebooks
JupyterLab - Project Jupyter の次世代ユーザーインターフェース をインストールする🤔
$ deno jupyter -h
Deno kernel for Jupyter notebooks Usage: deno jupyter [OPTIONS] Options: --conn <conn> Path to JSON file describing connection parameters, provided by Jupyter --install Installs kernelspec, requires 'jupyter' command to be available. --kernel Start the kernel -q, --quiet Suppress diagnostic output
$ deno jupyter --install
Warning "deno jupyter" is unstable and might change in the future. ✅ Deno kernelspec installed successfully.
Jupyter Kernel のインストール確認🤔
$ mamba run -n jupyterlab jupyter kernelspec list
Available kernels: python3 /home/tomoyan/miniforge3/envs/jupyterlab/share/jupyter/kernels/python3 xpython /home/tomoyan/miniforge3/envs/jupyterlab/share/jupyter/kernels/xpython xpython-raw /home/tomoyan/miniforge3/envs/jupyterlab/share/jupyter/kernels/xpython-raw deno /home/tomoyan/.local/share/jupyter/kernels/deno
tslab
tslab で TypeScript と JavaScript Kernel をインストールする場合は以下の手順を実行する🤔
事前に pnpm のインストールが必要😉
$ pnpm install -g tslab
Downloading zeromq@6.3.0: 6.99 MB/6.99 MB, done
WARN 6 deprecated subdependencies found: are-we-there-yet@3.0.1, gauge@4.0.4, glob@7.2.3, inflight@1.0.6, npmlog@6.0.2, sourcemap-codec@1.4.8-for-tslab@5.0.4: 3.28 MB/7.05 MB
Packages: +165
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Downloading @tslab/typescript-for-tslab@5.0.4: 7.05 MB/7.05 MB, done
Progress: resolved 166, reused 0, downloaded 165, added 165, done
/home/tomoyan/.local/share/pnpm/global/5:
+ tslab 1.0.22
╭ Warning ──────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Ignored build scripts: zeromq. │
│ Run "pnpm approve-builds -g" to pick which dependencies should be allowed to run scripts. │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────╯
Done in 29.3s using pnpm v10.6.1
$ pnpm approve-builds -g
? Choose which packages to build (Press <space> to select, <a> to toggle all, <i> to invert selection) …
❯ ● zeromq -> Enter
✔ Choose which packages to build (Press <space> to select, <a> to toggle all, <i> to invert selection) · zeromq
? The next packages will now be built: zeromq.
Do you approve? (y/N) ‣ false -> y
Do you approve? (y/N) · true
.pnpm/zeromq@6.3.0/node_modules/zeromq: Running install script, done in 544ms
動作確認🤔
$ tslab install --version
tslab 1.0.22
Jupyter の TypeScript kernel と JavaScript kernel をインストール🤔
$ mamba run -n jupyterlab tslab install
Running python3 /home/tomoyan/.local/share/pnpm/global/5/.pnpm/tslab@1.0.22/node_modules/tslab/python/install.py --tslab=tslab Installing TypeScript kernel spec Installing JavaScript kernel spec
Jupyter Kernel のインストール確認🤔
$ mamba run -n jupyterlab jupyter kernelspec list
Available kernels: python3 /home/tomoyan/miniforge3/envs/jupyterlab/share/jupyter/kernels/python3 xpython /home/tomoyan/miniforge3/envs/jupyterlab/share/jupyter/kernels/xpython xpython-raw /home/tomoyan/miniforge3/envs/jupyterlab/share/jupyter/kernels/xpython-raw deno /home/tomoyan/.local/share/jupyter/kernels/deno jslab /home/tomoyan/.local/share/jupyter/kernels/jslab jupyter_common /home/tomoyan/.local/share/jupyter/kernels/jupyter_common rust /home/tomoyan/.local/share/jupyter/kernels/rust tslab /home/tomoyan/.local/share/jupyter/kernels/tslab user-site-env /home/tomoyan/.local/share/jupyter/kernels/user-site-env
$ mamba run -n jupyterlab jupyter lab --ip=0.0.0.0 --port=28888 --no-browser