LoginSignup
0
0

More than 1 year has passed since last update.

create react appでyarn startでコケたときの解決法

Last updated at Posted at 2021-08-01

記事の定義

yarn start をすると下記のエラーが出てきました。
この記事では上記の解決法を記載する。

error An unexpected error occurred: "/Users/hoge/hogehoge/package.json: Unexpected string in JSON at position 185".

起きたこと&状況

  • ソースコード
pakege.json
{
  "name": "hoge",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3"
  }
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
}

  • バージョン
node -v
v14.17.4
yarn -v
1.22.10

解決方法

Scripts の前の } の後ろに , を追加する。
そしてScripts の }, を削除する。

pakege.json
{
  "name": "hoge",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3"
  }, 
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  }
}

余談

おそらく文字列("hoge")が続く場合は , で接続する必要性がある

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