みたぬメモ

地味にメモ

sh: typings: command not foundのエラーが出たときの対処法

angular2を始めるべくいろいろ始めようとインストールしていたとき、typingsフォルダの段階でインストールに失敗したので覚書。

ちなみに以下を参考に環境を整えようとしました。

blog.yuhiisk.com

 

・エラーが出ている段階
$ npm install
npm WARN angular-quickstart@1.0.0 No description
npm WARN angular-quickstart@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: weinre@2.0.0-pre-I0Z7U9OV (node_modules/weinre):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime '~/node_modules/.staging/weinre-4d9a3849/web/client/Images/scriptsIcon.png'

npm ERR! Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2017-08-01T09_02_54_297Z-debug.log

はて。このエラーにより、どうやらTypeScriptに必要なtypingsがインストールされていないようである。

そこで以下のコマンドで、個別にtypingsをインストールしようと試みる。

$ npm run typings install

これも以下のエラーが吐き出される。

sh: typings: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! angular-quickstart@1.0.0 typings: `typings "install"`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the angular-quickstart@1.0.0 typings 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!     /Users/user/.npm/_logs/2017-08-01T09_43_44_383Z-debug.log

typingsコマンドがbashにないですよ云々かんぬん怒られているようです。

 

・解決策

以下のコマンドを試した。

$ npm install typings -g

そして以下のコマンド再実行。

$ npm run typings install

結果。

> angular-quickstart@1.0.0 typings ~/angular2/first-angular2
> typings "install"

typings WARN deprecated 2016-11-21: "registry:dt/node#6.0.0+20160909174046" is deprecated (updated, replaced or removed)
typings WARN deprecated 2016-9-14: "registry:dt/core-js#0.0.0+20160725163759" is deprecated (updated, replaced or removed)
typings WARN deprecated 2016-10-25: "registry:dt/jasmine#2.2.0+20160621224255" is deprecated (updated, replaced or removed)

├── core-js (global)
├── jasmine (global)
└── node (global)

warnが出ているけどひとまずインストールされた。もしかしたらもっといい方法もあるかもしれないけどひとまずメモ書き。

 

参考:postinstall script 'typings install' fails. · Issue #54 · pablodenadai/angular2-seed-project · GitHub