LoginSignup
2
0

More than 1 year has passed since last update.

TypeScriptとExpressの環境構築

Last updated at Posted at 2022-03-26

はじめに

Webアプリケーションでよく利用されているExpressというフレームワークをサーバ側に、
TypeScriptをクライアント側にする環境構築の手順をまとめた

前提条件

npmがインストールされていること

手順

ターミナルを開き、ターミナルで次のコマンドを実行していく

1.TypeScriptをインストール

npm install -g typescript

2.次のコマンドを実行してpackage.jsonを作成します

npm init

※コマンド実行後は色々質問が来ますが、ここでは説明を省き、Enterキーを押していきます

3.package.jsonを作成したら、次のコマンドを実行します

yarn install

4.次のコマンドを実行し、tsconfig.jsonを作成します

tsc --init

5.VSCODEのエディタなどでpackage.jsonを開き次の1行を追加します

package.json
"moduleResolution": "node",

(例)package.json
スクリーンショット 2022-03-26 11.12.02.png

6.tsconfig.jsonを開き、 "noUnusedParameters"のコメントアウトを外し、true→falseに変更します

tsconfig.json
"noUnusedParameters": false,

(例)tsconfig.json
スクリーンショット 2022-03-26 11.12.26.png

※tsconfig.jsonに下記のエラーが発生している場合

  tsconfig.json で入力が見つかりませんでした。指定された 'include' パスは '["**/*"]' で、'exclude' パスは '["node_modules"]' でした。

→tsconfig.jsonの最後に"include"を追加すると解消できました
スクリーンショット 2022-03-26 11.46.37.png
それでも解決しない場合は調べてください
(検索ワード「tsconfig.json 入力が見つかりませんでした」など)

以上で環境構築が終わりです

2
0
3

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