LoginSignup
2
0

More than 1 year has passed since last update.

jsCoqのインストール

Last updated at Posted at 2021-05-16

1. はじめに

ローカル環境でjsCoqが使えるようにする。
jsCoqについては以下のページを参照。

2. 準備

以下の手順を踏む。

  1. Node.jsをインストール
  2. npmでhttp-serverをグローバルモードでインストール
  3. npmでjscoqをローカルにインストール

2-1. Windows10

2-1-1. Node.jsをインストール

以下のページからインストーラをダウンロードする。
Node.js
この記事を書いている段階の推奨版は14.17.0 LTSなので、そちらを選択する。

インストーラを実行し、デフォルトで進めていく。
ただし、Tools for Native Modulesは ”Automatically install the necessary tools..."はチェックを入れておく。

PowerShellなどターミナルを開き、以下のコマンドを実行してバージョンが表示されていれば、インストールは成功している。

> node --version
v14.17.0

2-1-2. npmでhttp-serverをインストール

ターミナルから以下コマンドを実行する。

> npm install -g http-server

Windowsの場合、スクリプトの実行が有効になっている必要がある。
以下のコマンドを実行し、結果がこのようになっている場合はスクリプト実行が無効になっている。

> Get-ExecutionPolicy
Restricted

スクリプト実行を有効にするには、以下のコマンドを実行する。

> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process

実行ポリシーの変更
実行ポリシーは、信頼されていないスクリプトからの保護に役立ちます。実行ポリシーを変更すると、about_Execution_Policies
のヘルプ トピック (https://go.microsoft.com/fwlink/?LinkID=135170)
で説明されているセキュリティ上の危険にさらされる可能性があります。実行ポリシーを変更しますか?
[Y] はい(Y)  [A] すべて続行(A)  [N] いいえ(N)  [L] すべて無視(L)  [S] 中断(S)  [?] ヘルプ (既定値は "N"): Y
> Get-ExecutionPolicy
RemoteSigned

2-1-3. jsCoqのインストールと起動

以下のように、適当な作業ディレクトリに移動し、jsCoqをインストールしてhttp-serverを起動する。

> mkdir jscoq
> cd jscoq
> npm install jscoq
> cp .\node_modules\jscoq\examples\npm-template.html .\index.html
> http-server

終了する場合はCtrl-C。

2-2. macOS

Homebrewでインストールすることを前提とする。

あらかじめアップデートしておく。

$ brew update
$ brew upgrade

2-2-1. nodebrewのインストール

nodebrewは、Node.jsのバージョン管理ツール。
ターミナルから以下のコマンドを実行する。

$ brew install nodebrew
$ mkdir -p ~/.nodebrew/src

さらに~/.bash_profileの最後尾に以下のスクリプトを追加する。

# nodebrew
export PATH=$HOME/.nodebrew/current/bin:$PATH

. ~/.bash_profileを実行しておく。

2-2-2. Node.jsのインストール

本家webページに記載されている推奨版14.17.0をインストールする。

$ nodebrew install v14.17.0
$ nodebrew use v14.17.0

2-2-3. npmでhttp-serverをインストール

ターミナルから以下コマンドを実行する。

$ npm install -g http-server

2-2-4. jsCoqのインストールと起動

以下のように、適当な作業ディレクトリに移動し、jsCoqをインストールしてhttp-serverを起動する。

$ mkdir jscoq
$ cd jscoq
$ npm install jscoq
$ cp ./node_modules/jscoq/examples/npm-template.html ./index.html
$ http-server

終了する場合はCtrl-C。

2-3. Ubuntu

2-3-1. Node.jsとnpmをインストール

ターミナルから以下のコマンドを実行する。

$ sudo apt install -y nodejs npm

以下のコマンドを実行してバージョンが表示されていれば、インストールは成功している。

$ node --version
v10.19.0

2-3-2. npmでhttp-serverをインストール

ターミナルから以下コマンドを実行する。

$ sudo npm install -g http-server

2-3-3. jsCoqのインストールと起動

以下のように、適当な作業ディレクトリに移動し、jsCoqをインストールしてhttp-serverを起動する。

$ mkdir jscoq
$ cd jscoq
$ npm install jscoq
$ cp ./node_modules/jscoq/examples/npm-template.html ./index.html
$ http-server

3. jsCoqを使う

3-1. ブラウザ起動

http-serverはデフォルトで8080を使用しているので、ブラウザから以下のURLで使用することができる。

3-2. キーボードショートカット

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0