質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%

Q&A

解決済

1回答

2926閲覧

Angular2でソースファイル変更時の自動コンパイルが動かない

kodai

総合スコア759

0グッド

0クリップ

投稿2016/08/28 12:28

Angular2のチュートリアルを始めたのですが、ソースファイルを更新しても自動検知・再コンパイルしてくれません。
npm start を実行したときに以下のエラーが出ていて、おそらくファイルの更新チェック用モジュールがエラーになっていると思われるのですが、解決策がわかりません・・・。どなたか教えてください。

node_modules/の削除や再インストールはなんどか実行してみましたが変わりませんでした。
サーバ(lite-server?)は起動して、コンテンツ自体は表示されています。起動したままソースファイルを編集・保存しても反映されず、サーバを停止・再起動すると反映されます。

bash

1$ node -v 2v6.4.0 3$ npm -v 43.10.3 5$ head package.json 6{ 7 "name": "angular2-quickstart", 8 "version": "1.0.0", 9 "scripts": { 10 "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ", 11 "lite": "lite-server", 12 "postinstall": "typings install", 13 "tsc": "tsc", 14 "tsc:w": "tsc -w", 15 "typings": "typings" 16$ npm start 17> angular2-quickstart@1.0.0 start ~/src/angular2-quickstart/tour-of-heros 18> tsc && concurrently "npm run tsc:w" "npm run lite" 19 20[0] 21[0] > angular2-quickstart@1.0.0 tsc:w ~/src/angular2-quickstart/tour-of-heros 22[0] > tsc -w 23[0] 24[1] 25[1] > angular2-quickstart@1.0.0 lite ~/src/angular2-quickstart/tour-of-heros 26[1] > lite-server 27[1] 28[0] fs.js:1431 29[0] throw error; 30[0] ^ 31[0] 32[0] Error: watch ~/src/angular2-quickstart/tour-of-heros ENOENT 33[0] at exports._errnoException (util.js:1026:11) 34[0] at FSWatcher.start (fs.js:1429:19) 35[0] at Object.fs.watch (fs.js:1456:11) 36[0] at addDirWatcher (~/src/angular2-quickstart/tour-of-heros/node_modules/typescript/lib/tsc.js:1036:39) 37[0] at Object.addFile (~/src/angular2-quickstart/tour-of-heros/node_modules/typescript/lib/tsc.js:1051:21) 38[0] at Object.watchFile (~/src/angular2-quickstart/tour-of-heros/node_modules/typescript/lib/tsc.js:1172:48) 39[0] at Object.executeCommandLine (~/src/angular2-quickstart/tour-of-heros/node_modules/typescript/lib/tsc.js:34546:44) 40[0] at Object.<anonymous> (~/src/angular2-quickstart/tour-of-heros/node_modules/typescript/lib/tsc.js:34877:4) 41[0] at Module._compile (module.js:556:32) 42[0] at Object.Module._extensions..js (module.js:565:10) 43[0] 44[0] npm 45[0] ERR! Darwin 15.6.0 46[0] npm ERR! argv "~/.nodebrew/node/v6.4.0/bin/node" "~/.nodebrew/node/v6.4.0/bin/npm" "run" "tsc:w" 47[0] npm ERR! node v6.4.0 48[0] npm ERR! npm v3.10.3 49[0] npm ERR! code ELIFECYCLE 50[0] npm ERR! angular2-quickstart@1.0.0 tsc:w: `tsc -w` 51[0] npm 52[0] ERR! Exit status 1 53[0] npm ERR! 54[0] npm 55[0] ERR! 56[0] Failed at the angular2-quickstart@1.0.0 tsc:w script 'tsc -w'. 57[0] npm ERR! Make sure you have the latest version of node.js and npm installed. 58[0] npm ERR! If you do, this is most likely a problem with the angular2-quickstart package, 59(...snip...)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

Error: watch ~/src/angular2-quickstart/tour-of-heros ENOENT

「なので、エラーとしてはそのディレクトリが見つからない」になるんですけど、
他の行見ると、そこにnode_modulesがあるので不明ですね。

QuickStartのStep 6までやってみましたが普通に動きました。
Node 6.3.1

ディレクトリは ~/src/angular2-quickstart/app
となるような構成です。

angular2-quickstartの下にtour-of-heros があるのが少し気にはなりますが。
( angular2-quickstart はディレクトリ以外(package.jsonとか)ないですよね?)

気になったのは私の環境だとログにはディレクトリはチルダではなく展開されて表示されています。
bashでもzshでも同様でした。

$ npm start > angular2-quickstart@1.0.0 start /Users/xxxxx/src/angular2-quickstart > tsc && concurrently "npm run tsc:w" "npm run lite" [0] [0] > angular2-quickstart@1.0.0 tsc:w /Users/xxxxx/src/angular2-quickstart [0] > tsc -w [0] [1] [1] > angular2-quickstart@1.0.0 lite /Users/xxxxx/src/angular2-quickstart [1] > lite-server [1] [1] Did not detect a `bs-config.json` or `bs-config.js` override file. Using lite-server defaults... [1] ** browser-sync config **

環境面では私は Nodebrew使ってないという違いはあります。

実行ユーザーが変わって ~ の指す場所が見えないぐらいしか思いつかないですね。
/tmpなど、フルパスで指定されそうなディレクトリにコピーしてみて実行したらどうなるかみてみるといいかもしれません。

あまりお力になれませんが参考まで。

投稿2016/08/28 14:25

flied_onion

総合スコア2604

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kodai

2016/08/28 15:59

試して頂いてありがとうございます。このチュートリアルの他の前にも別のチュートリアルをやっているのでディレクトリ構成はたしかに差異があります。 > 「なので、エラーとしてはそのディレクトリが見つからない」になるんですけど、 このエラー内容は理解できてなかったので参考になります。この辺りを中心に見てみます!
kodai

2016/08/28 16:25

原因不明ですがパス名が全て小文字になっており /Users/xxxxx なのに /users/xxxxx を見て ENOENT になっていたようです。 package.json などにもパスを指定する項目がなかったので、なぜこうなっているか不明ですが、とりあえず ln -s で /users を作って解決しました。ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問