LoginSignup
9
3

More than 1 year has passed since last update.

Windows 「 No files matching the pattern were found」 エラーを解決する。

Posted at

 結論

パスを記述している部分を、「\"」もしくは「¥"」で囲む!
例↓

format:prettier --write --ignore-path .gitignore \"./**/*.{js,jsx,ts,tsx,json,css}\"

成り行き

windowsでNext.js×TypeScript×Eslint×Prettierで環境構築をしている際、prettierのフォーマットを試しに実行するとエラーになりました。解決方法があまり出回っていなかったので投稿します。

当時の記述法はダブルクォーテーションでスクリプトを囲み、パスの部分をシングルクォーテーションで囲んでいました。
当時のpackage.jsonから該当箇所抜粋↓

"format": "prettier --write --ignore-path .gitignore './**/*.{js,jsx,ts,tsx,json,css}'"

実行結果↓

$ prettier --write --ignore-path .gitignore './**/*.{js,jsx,ts,tsx,json,css}'
[error] No files matching the pattern were found: "'./**/*.{js,jsx,ts,tsx,json,css}'".

エラーが出ちゃいます。

解決策

よく環境構築の方法を書いてくれている記事はこの書き方なのですが、これはMACの書き方のようです。
--no-error-on-unmatched-patternをパス前に記述するなど対策を試みましたが、そもそも根本的な解決ではなく変わらずエラーでした。
windowsの場合、シングルクォーテーションではなく、「\"」もしくは「¥"」で囲む必要があるみたいです。↓

format:prettier --write --ignore-path .gitignore \"./**/*.{js,jsx,ts,tsx,json,css}\"

実行結果↓

$ prettier --write --ignore-path .gitignore "./**/*.{js,jsx,ts,tsx,json,css}"
src\components\atoms\index.ts 8ms
・
・
・
Done in 1.07s.

解決しました!

9
3
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
9
3