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

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

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

Nuxt.jsは、ユニバーサルなSPAが開発可能なVue.jsベースのフレームワーク。UIの描画サポートに特化しており、SSRにおけるサーバーサイドとクライアントサイドのUIレンダリングなどさまざまな機能を持ちます。

Yarn

Yarnは、Facebook/Exponent/Google/Tildeが開発したJavaScriptのパッケージマネージャ。npmよりもインストールが速く、厳密にモジュールのバージョンを固定できるなど、npmの問題を解決。npmと互換性があり、同じpackage.jsonを使用できます。

Q&A

0回答

1171閲覧

Nuxt Fatal Errorの解決について

toshihirokato

総合スコア20

Nuxt.js

Nuxt.jsは、ユニバーサルなSPAが開発可能なVue.jsベースのフレームワーク。UIの描画サポートに特化しており、SSRにおけるサーバーサイドとクライアントサイドのUIレンダリングなどさまざまな機能を持ちます。

Yarn

Yarnは、Facebook/Exponent/Google/Tildeが開発したJavaScriptのパッケージマネージャ。npmよりもインストールが速く、厳密にモジュールのバージョンを固定できるなど、npmの問題を解決。npmと互換性があり、同じpackage.jsonを使用できます。

0グッド

0クリップ

投稿2019/10/28 04:01

前提・実現したいこと

現在、こちらのサイトの写経をしているのですが、
最後の yarn run generate を実行したところ、以下のエラーが発生いたしました。

発生している問題・エラーメッセージ

FATAL Could not compile template /Users/user/qiita-app/node_modules/@nuxt/vue-app/template/App.js: Cannot resolve "element-ui/lib/theme-chalk-index.css" from "/Users/user/qiita-app/app/element-ui/lib/theme-chalk-index.css" at Promise.all.templateFiles.map (node_modules/@nuxt/builder/dist/builder.js:6013:17) ╭───────────────────────────────────────────────────────────────────────╮ │ │ │ ✖ Nuxt Fatal Error │ │ │ │ Error: Could not compile template │ │ /Users/user/qiita-app/node_modules/@nuxt/vue-app/template/App.js: │ │ Cannot resolve "element-ui/lib/theme-chalk-index.css" from │ │ "/Users/user/qiita-app/app/element-ui/lib/theme-chalk-index.css" │ │ │ ╰───────────────────────────────────────────────────────────────────────╯ error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

該当のソースコード

nuxtconfigjs

1module.exports = { 2 mode: 'spa', 3 srcDir: 'app', 4 /* 5 ** Headers of the page 6 */ 7 head: { 8 title: 'qiita-app', 9 meta: [ 10 { charset: 'utf-8' }, 11 { name: 'viewport', content: 'width=device-width, initial-scale=1' }, 12 { hid: 'description', name: 'description', content: 'Nuxt.js project' } 13 ], 14 link: [ 15 { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }, 16 { 17 rel: 'stylesheet', 18 href: 'https://fonts.googleapis.com/css?family=M+PLUS+1p' 19 } 20 ] 21 }, 22 plugins: [ 23 { src: "@plugins/element-ui", ssr: false }, 24 { src: "@plugins/filters.js", ssr: false } 25 ], 26 // pluginsにelement-ui用のプラグイン、filters用のプラグインを導入する 27 // filtersは、テキストを変換する処理を担っている 28 css: ["element-ui/lib/theme-chalk-index.css"], 29 // cssプロパティで設定したファイルはグローバルに適用されるため、ここにelement-uiを指定する 30 /* 31 ** Customize the progress bar color 32 */ 33 loading: { color: '#3B8070' }, 34 /* 35 ** Build configuration 36 */ 37 build: { 38 vendor: ["axios", "element-ui", "dayjs"], 39 // dayjsはmomentの代わりで、momentよりサイズが小さい 40 /* 41 ** Run ESLint on save 42 */ 43 extend(config, { isDev, isClient }) { 44 if (isDev && isClient) { 45 config.module.rules.push({ 46 enforce: 'pre', 47 test: /.(js|vue)$/, 48 loader: 'eslint-loader', 49 exclude: /(node_modules)/ 50 }); 51 } 52 config.module.rules = config.module.rules.map(rule => { 53 if (rule.loader === "babel-loader") { 54 rule.exclude = /node_modules/; 55 } 56 return rule; 57 }); 58 } 59 } 60 // buildプロパティのextendには、babelやeslintの適用除外のディレクトリを指定する 61 // また、buildプロパティのvendorにaxios, element-ui, dayjsを指定して全体のサイズをコンパクトにする 62}; 63

試したこと

nuxt.config.js ファイル内の** module.exports** を export default に変更しましたが、エラーを解決できませんでした。

補足情報(FW/ツールのバージョンなど)

packagejson

1{ 2 "name": "qiita-app", 3 "version": "1.0.0", 4 "description": "Nuxt.js project", 5 "author": "", 6 "private": true, 7 "scripts": { 8 "dev": "nuxt", 9 "build": "nuxt build", 10 "start": "nuxt start", 11 "generate": "nuxt generate", 12 "lint": "eslint --ext .js,.vue --ignore-path .gitignore .", 13 "precommit": "npm run lint" 14 }, 15 "dependencies": { 16 "axios": "^0.19.0", 17 "dayjs": "^1.8.16", 18 "element-ui": "^2.12.0", 19 "nuxt": "^2.0.0", 20 "yarn": "^1.19.1" 21 }, 22 "devDependencies": { 23 "babel-eslint": "^10.0.1", 24 "eslint": "^6.6.0", 25 "eslint-friendly-formatter": "^4.0.1", 26 "eslint-loader": "^2.1.1", 27 "eslint-plugin-vue": "^4.0.0" 28 } 29} 30

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

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

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

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

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

nt4c

2019/10/28 04:53

「Cannot resolve "element-ui/lib/theme-chalk-index.css"...」とあるのでelement-uiのcss周りのエラーだと思いますが、element-uiのバージョンを参考元と合わせても解消はされませんか?
toshihirokato

2019/10/29 09:16

ありがとうございます! 早速試してみます????‍♂️????
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問