0

I'm following this tutorial: https://laravel-news.com/your-first-laravel-9-application

But possibly having an issue with one command and I'm definately having an issue with another command.

When I get to this line: npm install && npm run dev

The terminal never seems to finish, it never returns back to my bash command prompt. It just sits there with this output and a blinking cursor, I'm not returned to my bash prompt until I hit Ctrl-C.

  VITE v3.2.5  ready in 344 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose

  LARAVEL v9.43.0  plugin v0.7.1

  ➜  APP_URL: http://localhost

And when I get to this line, I'm actually getting an error: php artisan migrate

   Illuminate\Database\QueryException 

  could not find driver (SQL: PRAGMA foreign_keys = ON;)

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
    756▕         // If an exception occurs when attempting to run a query, we'll format the error
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $query, $this->prepareBindings($bindings), $e
    762▕             );
    763▕         }
    764▕     }

      +41 vendor frames 
  42  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

Here's my .env database block, I have it set exactly as he has it in the tutorial:

DB_CONNECTION=sqlite
DB_DATABASE=/var/www/html/bookmarker/database/database.sqlite
DB_FOREIGN_KEYS=true

I'm having a hard enough time learning laravel beceause of how everyone wants to teach it, but I can't even struggle through that because I have get to get a tutorial or course project without encountering one or more project stopping errors. Any/all help appreciated, thanks.

  • 2
    ``npm run dev`` will start the Vite development server which will keep running until stopped, will keep looking for changes and serve updated asset files. You should run that command in a different cmd tab. – OMi Shah Dec 11 '22 at 15:43
  • or run ``npm run build`` to build production files of assets. – OMi Shah Dec 11 '22 at 15:44
  • You also need the [pdo-sqlite php extension](https://www.php.net/manual/en/ref.pdo-sqlite.php) to use sqlite – apokryfos Dec 11 '22 at 15:47

1 Answers1

1

I'm guessing you're still super new to the community. Welcome aboard chief.


To answer your questions;

The very first commands npm install && npm run dev are used to install the frontend parts of Laravel. It uses Vite as a bundler in the new versions (which is a replacement from Laravel Mix and webpack for older versions).


Now your terminal never returns becase npm run dev actually runs a vite development server for you which stays running in the current terminal session. It allows your CSS and JS to be automatically bundled and minified (depending on the settings you have in your vite configs).


The second error you're getting which is could not find driver. It means that the sqlite driver that php needs to interact with sqlite databases was not found.

Installing it depends on your environment and OS. Try googling "How to install php sqlite driver for [OS]" which might give you a fair idea of how to get started solving this issue.


Now onto the issue of learning Laravel. I'm self-taught and I know the agony of finding good resources. But from my experience, I can recommend https://laracasts.com.

Jeffrey Way, the creator of Laracasts, and the others on Laracasts are GREAT! I have learnt a lot from them myself.

Here's a link to a series that I've enjoyed watching and learning from so much (Even though I'm not really a beginner ).

https://laracasts.com/series/laravel-8-from-scratch


Note 1: that it's required to pay a subscription to Laracasts if you're interested in their videos but It's an investment I recommend if you're serious about Laravel and your career as a developer.

Note 2: I'm in no way, shape or form associated with Laracasts and will gain nothing from promoting them. This is just my personal recommendation from my personal experience. Feel free to disagree with me.

Michael Yousrie
  • 1,132
  • 2
  • 10
  • 20