skyrpex / laravel-nuxt

Build a SPA with Laravel and Nuxt.
MIT License
123 stars 21 forks source link

failed to open stream: No such file or directory #4

Closed iliyaZelenko closed 6 years ago

iliyaZelenko commented 6 years ago

Hi, package looks good. When i run laravel-nuxt dev it shows me

[laravel] Laravel development server started: http://127.0.0.1:8001

i opened http://localhost:8000 and saw this error

after i run laravel-nuxt build && laravel-nuxt dev it show me production version and hot-code reloading does not work.

I made it work by replacing the following

Route::get(
    '{uri}',
    '\\'.Pallares\LaravelNuxt\Controllers\NuxtController::class
)->where('uri', '.*');
Route::get('{uri}', function () {
    $source = App::environment('local') ? 'http://localhost:8000/__laravel_nuxt__' : storage_path('app/nuxt/index.html');

    return file_get_contents($source);
})->where('uri', '.*');

Here is my config:

module.exports = laravelNuxt({
  mode: 'spa',

  env: {
    localeDefault: 'ru',
    avatarSizes: {
      lg: 320,
      md: 200,
      sm: 133
    },
    dateFormats: {
      main: 'YYYY-MM-DD'
    },
  },

  router: {
    middleware: 'global'
  },

  /*
  ** Headers of the page
  */
  head: {
    title: 'Заголовок',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: 'Описание' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
      { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons' }
    ]
  },
  plugins: [
    { src: '~/plugins/vuetify' },
    { src: '~/plugins/vee-validate' }, // , ssr: false izitoast
    { src: '~/plugins/fontawesome' }, // , ssr: true
    { src: '~/plugins/vue-notifications', ssr: false },
    // { src: '~/plugins/vue-affix', ssr: false },
    { src: '~/plugins/vuex-shared-mutations.js', ssr: false },
    { src: '~/plugins/dayjs.js' },
    { src: '~/plugins/filters.js' }
  ],
  modules: [
    '@nuxtjs/axios',
    '@nuxtjs/auth'
  ],
  css: [
    '~/styles/app.styl'
  ],
  /*
  ** Customize the progress bar color
  */
  // loading: { color: '#3B8070' },
  loading: {
    color: '#1976D2',
    height: '4px'
  },
  /*
   ** Авторизация
   */
  auth: {
    vuex: {
      namespace: 'nuxtAuth'
    },
    strategies: {
      local: {
        endpoints: {
          login: { url: '/api/auth/login', method: 'post', propertyName: 'access_token' },
          logout: { url: '/api/auth/logout', method: 'post' },
          user: { url: '/api/auth/user', method: 'get', propertyName: 'user' }
        }
      }
    },
    redirect: {
      login: '/auth/signin',
      callback: '/auth/signin', // TODO сделать красивую страницу
      logout: '/' // возможно логичней не перенаправлять(false)
    }
  },

  generate: {
    routes: [
      '/auth/socialite/google',
      '/auth/socialite/facebook',
      '/auth/socialite/vkontakte',
      '/auth/socialite/instagram',
      '/auth/socialite/reddit'
    ]
  },

  /*
  ** Build configuration
  */
  build: {
    vendor: [
      'vuetify',
      'vee-validate',
      'vue-izitoast',
      'vue-notifications',
      '@fortawesome/fontawesome',
      'js-cookie'
    ],
    extractCSS: true,
    /*
    ** Run ESLint on save
    */
    extend (config, ctx) {
      if (ctx.isDev && ctx.isClient) {
        config.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/
        })
      }
    }
  }
})
skyrpex commented 6 years ago

Hi there!

By the looks of your screenshot, it seems that the dev server is not on. Could you please try the following and paste here the output?

iliyaZelenko commented 6 years ago

Thank you for help! I did everything according to instructions, everything should work. I followed all steps and got the same error

If i have public/_nuxt files, then laravel-nuxt dev it show me production version and hot-code reloading does not work. If there is no solution, then I could easily publish my project on the github for you.

skyrpex commented 6 years ago

Looks like Laravel isn't recognizing that the dev mode is on, but I don't know why. Publishing the project would be helpful, yeah!

Just before that, could you please put your project in a directory without whitespaces? Somewhere like D:\Projects\LaravelNuxtAuthStarter.

iliyaZelenko commented 6 years ago

https://github.com/iliyaZelenko/laravel-nuxt Folder name does not affect. I installed my project from github and everything worked , but then I did something and again stopped working. Probably because I cached configs in development, I do not remember. Now I'm trying to understand.

I dont now why, i changed some code on github, install project again and get new error after laravel-nuxt dev error on this line

laravel-nuxt build worked correctly

skyrpex commented 6 years ago

will take a look! this weekend I'm out so will review in a few days

On Fri, Jul 27, 2018, 16:05 Илья notifications@github.com wrote:

https://github.com/iliyaZelenko/laravel-nuxt Folder name does not affect. I installed my project from github and everything worked , but then I did something and again stopped working. Probably because I cached configs in development, I do not remember. Now I'm trying to understand.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/skyrpex/laravel-nuxt/issues/4#issuecomment-408428823, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBxELTd5phaziKQWUsg9jhfw_xrOXpTks5uKx4ygaJpZM4VXa7i .

skyrpex commented 6 years ago

This issue is solved with your MR, right? https://github.com/skyrpex/laravel-nuxt-js/pull/7

iliyaZelenko commented 6 years ago

This solved the problem in the last screenshot. But I did not solve the problem because of which I created this question. Try to install my project and run yarn dev, this should give this error.

iliyaZelenko commented 6 years ago

Although wait, I reinstalled the project and it looks like it works, but it may stop working after something.

skyrpex commented 6 years ago

Hello again, I was on vacation :)

So is it working then? I'll close the issue for now, feel free to reopen it if needed.