LoginSignup
5
5

More than 3 years have passed since last update.

npm run tsc --init でハマった話

Last updated at Posted at 2020-05-22

Typescriptのプロジェクト始めようと思って、npm run tsc --initでハマった
解決策がほかの時にも気を付けるべき内容だったので、残しておく

起こったエラー

typescriptをインストール

npm install typescript

package.jsonにtscを登録

package.json
  "scripts": {
    "tsc": "tsc"
  },

tsconfig.jsonを作成

npm run tsc --init

あれ?

実行結果
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test@1.0.0 tsc: `tsc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test@1.0.0 tsc script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\XXXX\AppData\Roaming\npm-cache\_logs\2020-05-22T18_01_55_736Z-debug.log

解決策

解決策はこちらにありました。
npm run (npm run-script) コマンドで実行するスクリプトに引数を渡す。2017

こう書かないといけないんですね。

npm run tsc -- --init
実行結果
message TS6071: Successfully created a tsconfig.json file.

うまくできました。

今までもnpm run command --optionでできてたと思ってたけど、運よく?運悪く?そういう場面に出会ってこなかっただけだったっぽい

5
5
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
5
5