前提・実現したいこと
現在、こちらのサイトの写経をしているのですが、
最後の 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
あなたの回答
tips
プレビュー