LoginSignup
4
5

More than 5 years have passed since last update.

Nuxt.js の公式 starter が動かなかった件

Last updated at Posted at 2018-05-29

公式のスターターを使って Nuxt.js 導入しようとすると……

npm run dev 実行したところエラーが発生し、ローカルサーバが起動しない。

※エラーメッセージ抜粋です

 ERROR  Failed to compile with 5 errors                                                                                                                                                                                                                                   13:03:30
 error  in ./.nuxt/components/nuxt-error.vue

Module build failed: Error: No parser and no file path given, couldn't infer a parser.
    at normalize (<!-- DIRECTORY -->\node_modules\prettier\index.js:7051:13)
    at formatWithCursor (<!-- DIRECTORY -->\node_modules\prettier\index.js:10370:12)
    at <!-- DIRECTORY -->\node_modules\prettier\index.js:31115:15
    at Object.format (<!-- DIRECTORY -->\node_modules\prettier\index.js:31134:12)
    at Object.module.exports (<!-- DIRECTORY -->\node_modules\vue-loader\lib\template-compiler\index.js:80:23)

 @ ./.nuxt/components/nuxt-error.vue 11:0-379
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi webpack-hot-middleware/client?name=client&reload=true&timeout=30000&path=/__webpack_hmr ./.nuxt/client.js

原因

prettierのバージョンが「1.13.0」になっているため
※細かい原因は未確認

package-lock.json
    "prettier": {
      "version": "1.13.0",
      "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.13.0.tgz",
      "integrity": "sha512-ubNahzMwHtdrSVGMMNabOHSeBKvZu+N5Z7Tu2CvbTexffL6aHwwOc7/fvEaWYTtvu4CtXnniHGA2vxV/NIH6KQ=="
    },

対応

1.12.1にダウングレードすれば動作しました。(以下参考にしました。)

$ npm i prettier@1.12.1 --save-dev --save-exact

まさか Nuxt.js 始めた直後に躓くとは思わなかった、、、

4
5
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
4
5