javascript - Vue js build is failing - Stack Overflow

I've got an existing web app made using Laravel. I'm moving my project's frontend to Vue

I've got an existing web app made using Laravel. I'm moving my project's frontend to Vuejs. So I've modified my view app.blade.php to be:

@include('layout.header')
<div id="app">
    <router-view></router-view>
</div>
@include('layout.footer')

My web.php route file now is:

Route::get('/{any}', function() {
    return view('layout.app');
})->where('any', '.*');

Within resources/js/ I have my routes file which uses Vue-router (already installed):

import NotFound from './pages/NotFound'
import Home from "./pages/Home"


export default {
    mode: 'history',

    routes: [
        {
            path: '*',
            ponent: NotFound
        },
        {
            path: '/',
            ponent: Home
        }
    ]
}

and my app.js file is:

import './bootstrap'
import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'

Vue.use(VueRouter)

const app = new Vue({
    el: '#app',
    router: new VueRouter(routes)
});

For testing purposes I created a simple Home.vue ponent located in resources\js\pages. This is the ponent:

<template>
    <div>
        <h1>This is home</h1>
    </div>
</template>

<script>
    export default {}
</script>

but it never loads. When piling I'm getting the following error:

ERROR Failed to pile with 1 errors 7:54:59 PM

error in ./resources/js/pages/Home.js

Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: ENOENT: no such file or directory, open '/Users/bigweld/Sites/championshiprecords/resources/js/pages/Home.js'

@ ./resources/js/routes.js 2:0-32 10:15-19 @ ./resources/js/app.js @ multi ./resources/js/app.js ./resources/sass/app.scss

by the way, my webpack.mix.js is simply:

const mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js')
   .sass('resources/sass/app.scss', 'public/css')
   .copy('resources/images', 'public/images', true);

Any idea what's going on here?

I've got an existing web app made using Laravel. I'm moving my project's frontend to Vuejs. So I've modified my view app.blade.php to be:

@include('layout.header')
<div id="app">
    <router-view></router-view>
</div>
@include('layout.footer')

My web.php route file now is:

Route::get('/{any}', function() {
    return view('layout.app');
})->where('any', '.*');

Within resources/js/ I have my routes file which uses Vue-router (already installed):

import NotFound from './pages/NotFound'
import Home from "./pages/Home"


export default {
    mode: 'history',

    routes: [
        {
            path: '*',
            ponent: NotFound
        },
        {
            path: '/',
            ponent: Home
        }
    ]
}

and my app.js file is:

import './bootstrap'
import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'

Vue.use(VueRouter)

const app = new Vue({
    el: '#app',
    router: new VueRouter(routes)
});

For testing purposes I created a simple Home.vue ponent located in resources\js\pages. This is the ponent:

<template>
    <div>
        <h1>This is home</h1>
    </div>
</template>

<script>
    export default {}
</script>

but it never loads. When piling I'm getting the following error:

ERROR Failed to pile with 1 errors 7:54:59 PM

error in ./resources/js/pages/Home.js

Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: ENOENT: no such file or directory, open '/Users/bigweld/Sites/championshiprecords/resources/js/pages/Home.js'

@ ./resources/js/routes.js 2:0-32 10:15-19 @ ./resources/js/app.js @ multi ./resources/js/app.js ./resources/sass/app.scss

by the way, my webpack.mix.js is simply:

const mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js')
   .sass('resources/sass/app.scss', 'public/css')
   .copy('resources/images', 'public/images', true);

Any idea what's going on here?

Share Improve this question edited Jul 16, 2019 at 1:10 MrCujo asked Jul 15, 2019 at 3:04 MrCujoMrCujo 1,3334 gold badges44 silver badges85 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

You are very close but you are missing something while importing

SO

FROM

import NotFound from './pages/NotFound'
import Home from "./pages/Home"

TO

import NotFound from './pages/NotFound.vue'
import Home from "./pages/Home.vue"

You are missing the vue extension

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745469168a4629053.html

相关推荐

  • javascript - Vue js build is failing - Stack Overflow

    I've got an existing web app made using Laravel. I'm moving my project's frontend to Vue

    2小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信