typescript - Google ColabでDeno Jupyterカーネルをテストする
私はGoogle Colabのインストールや設定の問題に直面しています。
私の目的: denoベースのJupyterノートブックカーネルで直接TypeScriptを実行すること。
私の質問: すべてを期待通りに正しくインストールできましたか、それともランタイムタイプを変更した後にノートブック内でJavascript/Typescriptを直接実行するために必要な別のライブラリがありますか?
私の手順を再現するには:
Google Colab にアクセスして新しいノートブックを開きます: https://colab.google/ そして、以下の各コマンドを個々のノートブックセルで直接実行します。
!pip install jupyterlab
Requirement already satisfied: jupyterlab in /usr/local/lib/python3.10/dist-packages (4.0.8)
Requirement already satisfied: async-lru>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from jupyterlab) (2.0.4)
....
- !curl -fsSL https://deno.land/x/install/install.sh | sudo DENO_INSTALL=/usr/local sh
######################################################################## 100.0%
Archive: /usr/local/bin/deno.zip
inflating: /usr/local/bin/deno
Deno was installed successfully to /usr/local/bin/deno
Run 'deno --help' to get started
- !deno --version
deno 1.38.0 (release, x86_64-unknown-linux-gnu)
v8 12.0.267.1
typescript 5.2.2
- !jupyter kernelspec list
Available kernels:
deno /root/.local/share/jupyter/kernels/deno
ir /usr/local/share/jupyter/kernels/ir
python3 /usr/local/share/jupyter/kernels/python3
- !deno jupyter --unstable
ℹ️ Deno kernel is not yet installed, run `deno jupyter --unstable --install` to set it up
- !deno jupyter --unstable --install
[InstallKernelSpec] Installed kernelspec deno in /root/.local/share/jupyter/kernels/deno
✅ Deno kernelspec installed successfully.
- !deno run https://examples.deno.land/hello-world.ts
Download https://examples.deno.land/hello-world.ts
Hello, World!
- もし私がセルで次のコードを実行すると、動作しますが
%%javascript
let x = 5;
let y = 2;
let z = x + y;
element.textContent = z
予想通り、JavaScriptはランタイムを変更しない限り、セル内で直接実行されません。次のステップでそれに取り組みましょう :)
let x = 5;
let y = 2;
let z = x + y;
console.log(z);
File "<ipython-input-2-43a8c54cf62a>", line 1
let x = 5;
^
SyntaxError: invalid syntax
- ランタイム > ランタイムの種類を変更 > Deno
- ただ「接続中」と表示されるだけで、何も起こらず、次のポップアップが表示されます。
await connected: disconnected
Error: await connected: disconnected
at https://ssl.gstatic.com/colaboratory-static/common/7ecc98b5a079533f6e1c231d23497bd7/external_polymer_binary.js:7118:372
この質問についてのどんな助けでも感謝します。あらかじめありがとうございます!

