Q&A
#背景
Laravelとvue.jsを使ってチャットのwebサービスを作っていました。
こちらのサイトを参考にしております。
https://dev.to/mezie/how-to-build-a-laravel-chat-app-with-pusher-2e2o
laravel-echoとpusherを使ったリアルタイムチャットです。
eventの作成など一通り終わった後で、Laravel Mixを使ってJavaScriptファイルをコンパイルしようとした所で以下のようなエラーが出ました。
エラーコードを読んだ感じだとコンパイルに失敗していて./resources/sass/app.scssにエラーがあるとの事なのですが、特にapp.scssは弄った覚えがないです。
##エラーコード
xxxMacBook:laravel_chat xxx$ npm run dev > @ dev /Users/xxx/Desktop/laravel_chat > npm run development > @ development /Users/xxx/Desktop/laravel_chat > cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js 98% after emitting SizeLimitsPlugin ERROR Failed to compile with 2 errors 16:01:00 error in ./resources/sass/app.scss Module build failed (from ./node_modules/css-loader/index.js): ModuleBuildError: Module build failed (from ./node_modules/sass-loader/lib/loader.js): @import "utilities/clearfix"; ^ Can't find stylesheet to import. ╷ 4 │ @import "utilities/clearfix"; │ ^^^^^^^^^^^^^^^^^^^^ ╵ node_modules/bootstrap/scss/_utilities.scss 4:9 @import node_modules/bootstrap/scss/bootstrap.scss 43:9 @import stdin 8:9 root stylesheet in error in ./resources/sass/app.scss Module build failed (from ./node_modules/sass-loader/lib/loader.js): @import "utilities/clearfix"; ^ Can't find stylesheet to import. ╷ 4 │ @import "utilities/clearfix"; │ ^^^^^^^^^^^^^^^^^^^^ ╵ node_modules/bootstrap/scss/_utilities.scss 4:9 @import node_modules/bootstrap/scss/bootstrap.scss 43:9 @import stdin 8:9 root stylesheet in /Users/xxx/Desktop/laravel_chat/node_modules/bootstrap/scss/_utilities.scss (line 4, column 9) @ ./resources/sass/app.scss 2:14-255 Asset Size Chunks Chunk Names /js/app.js 1.68 MiB /js/app [emitted] /js/app ERROR in ./resources/sass/app.scss Module build failed (from ./node_modules/css-loader/index.js): ModuleBuildError: Module build failed (from ./node_modules/sass-loader/lib/loader.js): @import "utilities/clearfix"; ^ Can't find stylesheet to import. ╷ 4 │ @import "utilities/clearfix"; │ ^^^^^^^^^^^^^^^^^^^^ ╵ node_modules/bootstrap/scss/_utilities.scss 4:9 @import node_modules/bootstrap/scss/bootstrap.scss 43:9 @import stdin 8:9 root stylesheet ERROR in ./resources/sass/app.scss (./node_modules/css-loader??ref--5-2!./node_modules/postcss-loader/src??postcss0!./node_modules/resolve-url-loader??ref--5-4!./node_modules/sass-loader/lib/loader.js??ref--5-5!./resources/sass/app.scss) Module build failed (from ./node_modules/sass-loader/lib/loader.js): @import "utilities/clearfix"; ^ Can't find stylesheet to import. ╷ 4 │ @import "utilities/clearfix"; │ ^^^^^^^^^^^^^^^^^^^^ ╵ node_modules/bootstrap/scss/_utilities.scss 4:9 @import node_modules/bootstrap/scss/bootstrap.scss 43:9 @import stdin 8:9 root stylesheet in /Users/xx/Desktop/laravel_chat/node_modules/bootstrap/scss/_utilities.scss (line 4, column 9) @ ./resources/sass/app.scss 2:14-255 npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js` npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the @ development script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /Users/xxx/.npm/_logs/2019-08-04T07_01_02_384Z-debug.log npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! @ dev: `npm run development` npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the @ dev script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /Users/xxx/.npm/_logs/2019-08-04T07_01_02_409Z-debug.log
##app.scss
// Fonts @import url('https://fonts.googleapis.com/css?family=Nunito'); // Variables @import 'variables'; // Bootstrap @import '~bootstrap/scss/bootstrap';
##app.js
/** * First we will load all of this project's JavaScript dependencies which * includes Vue and other libraries. It is a great starting point when * building robust, powerful web applications using Vue and Laravel. */ require('./bootstrap'); window.Vue = require('vue'); /** * The following block of code may be used to automatically register your * Vue components. It will recursively scan this directory for the Vue * components and automatically register them with their "basename". * * Eg. ./components/ExampleComponent.vue -> <example-component></example-component> */ // const files = require.context('./', true, /.vue$/i); // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default)); Vue.component('chat-messages', require('./components/ChatMessages.vue')); Vue.component('chat-form', require('./components/ChatForm.vue')); /** * Next, we will create a fresh Vue application instance and attach it to * the page. Then, you may begin adding components to this application * or customize the JavaScript scaffolding to fit your unique needs. */ const app = new Vue({ el: '#app', data: { messages:[] }, created() { this.fetchMessages(); Echo.private('chat') .listen('MessageSent', (e) => { this.message.push({ message: e.message.message, user: e.user }); }); }, methods: { fetchMessages() { axions.get('/messages').then(response => { this.messages = response.data; }); }, addMessage(message) { this.message.push(message); axios.post('/messages', message).then(response => { console.log(response.data); }); } } });
回答1件
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。