npm run devが上手く行かない
解決済
回答 1
投稿
- 評価
- クリップ 2
- VIEW 4,527
背景
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);
});
}
}
});
-
気になる質問をクリップする
クリップした質問は、後からいつでもマイページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
クリップを取り消します
-
良い質問の評価を上げる
以下のような質問は評価を上げましょう
- 質問内容が明確
- 自分も答えを知りたい
- 質問者以外のユーザにも役立つ
評価が高い質問は、TOPページの「注目」タブのフィードに表示されやすくなります。
質問の評価を上げたことを取り消します
-
評価を下げられる数の上限に達しました
評価を下げることができません
- 1日5回まで評価を下げられます
- 1日に1ユーザに対して2回まで評価を下げられます
質問の評価を下げる
teratailでは下記のような質問を「具体的に困っていることがない質問」、「サイトポリシーに違反する質問」と定義し、推奨していません。
- プログラミングに関係のない質問
- やってほしいことだけを記載した丸投げの質問
- 問題・課題が含まれていない質問
- 意図的に内容が抹消された質問
- 過去に投稿した質問と同じ内容の質問
- 広告と受け取られるような投稿
評価が下がると、TOPページの「アクティブ」「注目」タブのフィードに表示されにくくなります。
質問の評価を下げたことを取り消します
この機能は開放されていません
評価を下げる条件を満たしてません
質問の評価を下げる機能の利用条件
この機能を利用するためには、以下の事項を行う必要があります。
- 質問回答など一定の行動
-
メールアドレスの認証
メールアドレスの認証
-
質問評価に関するヘルプページの閲覧
質問評価に関するヘルプページの閲覧
checkベストアンサー
0
app.scss自体ではなく,そこでimportされている `~bootstrap/scss/bootstrap' の方でエラーが起こっているように見えます。
おそらく"utilities/clearfix"のパスが解決できていないのだと思われます
投稿
-
回答の評価を上げる
以下のような回答は評価を上げましょう
- 正しい回答
- わかりやすい回答
- ためになる回答
評価が高い回答ほどページの上位に表示されます。
-
回答の評価を下げる
下記のような回答は推奨されていません。
- 間違っている回答
- 質問の回答になっていない投稿
- スパムや攻撃的な表現を用いた投稿
評価を下げる際はその理由を明確に伝え、適切な回答に修正してもらいましょう。
15分調べてもわからないことは、teratailで質問しよう!
- ただいまの回答率 88.22%
- 質問をまとめることで、思考を整理して素早く解決
- テンプレート機能で、簡単に質問をまとめられる