2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Angular2 RC5 Uncaught TypeError: uri.match is not a function に対処する

Last updated at Posted at 2016-08-20

開発中のAngular2アプリを、RC4からRC5にアップデートしたら、

Uncaught TypeError: uri.match is not a function

というエラーが表示されて、画面が全く表示されなくなった。

どうやら

  • Webpackを使っている
  • 利用しているライブラリのコンポーネントが moduleId を使っている

場合にエラーが発生する模様。

とか

あたりで議論されてて、そのうち修正されると思われますが、今は https://github.com/AngularClass/angular2-seed/commit/84aacc18682bbe38631cd3c457d9e90944d6fd0e に記載されている方法で回避した。

https://www.npmjs.com/package/string-replace-loader を導入して、webpack.config.ts に以下を追記。

webpack.config.ts

// 省略

module: {
  preLoaders: [
  // 省略
  
  /* FIXME: Angular2 バグ回避 あとで消す */
  {
      test: /.js$/,
      loader: 'string-replace-loader',
      query: {
        search: 'moduleId: module.id,',
        replace: '',
        flags: 'g'
      }
  }

js読み込む時に、 moduleId: module.id という文字列を消してしまう、という方法。

強引だが、なるほど、こんな解決方法もあるのかと関心した。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?