I am trying to run a laravel app in my local system. I have followed the https://gist.github.com/hootlex/da59b91c628a6688ceb1 link. I run the command php artisan serve command, and when I browse it, then produces the error
PHP Fatal error: Uncaught Exception: Unable to locate Mix file: /css/vendor.css. Please check your webpack.mix.js output paths and try again. in /var/www/html/laravel-app/app/helpers.php:439
In the specified line of helpers.php, it has
if (! isset($manifest[$path])) {
throw new Exception(
"Unable to locate Mix file: {$path}. Please check your ".
'webpack.mix.js output paths and try again.'
);
}
public/mix-manifest.json
{
"/mix.js": "/mix.js"
}
I couldn't sort it out. Please help. Thanks
The blade file you're loading obviously has mix('/css/vendor.css') call. You either comment out this line(s) or install npm then build your assets.
Your manifest file doesn't have /css/vendor.css but if you check your blade files (views) you'll see you are calling mix('/css/vendor.css'). So if you find and comment out this line(s) your problem will be solved.
Ideally, mix() is used for loading assets that were built by webpack. It will then take care of the versioning string for you. How mix can be used is detailed in the documentation. I will refrain myself from discussing that here.
You've built your assets by running npm run dev or similar commands. And then the manifest file doesn't contain those assets mapping. And your public directory doesn't have those assets as well. Then it's safe to assume that you can remove those mix calls from your blade (views) files.
If you have the assets built in your public directory then you can load those assets by assets function.
Lastly, you should know your assets first, before loading them to your site. I get the notion that you don't have any clue where those assets came from, so you shouldn't load them in the first place.
This happened with me and after spending quite some time and effort, I did manage to figure out what was happening and how to fix it.
Here's what happens:
You update your webpack.mix.js file with the destination where you wish to publish your compiled JS and CSS files respectively.
mix.js('resources/js/app.js', 'public/js').vue();
Mix compiles and stores the hence generated CSS and JS files within their respective destination folders when you run npm run dev or npm run watch.
laravel-app (Your laravel app root folder)
\public
\css
\app.css
\js
\app.js
When you open the application in your browser with, say Valet, Laravel spits out the following error message:
Unable to locate Mix file: /js/app.js
(or)
Unable to locate Mix file: /css/app.css
Something worth noting on the Uncaught Exception screen though, is that Laravel by default attempts to look for the files at localhost:8080. Implied that Laravel is looking for the files respectively at:
localhost:8080\css\app.css
(and)
localhost:8080\js\app.js
Hence, if your hostname or port is anything other than localhost:8080, Laravel would not be able to find your files. For example, if you're using Valet, your default URL would become laravel-app.test where laravel-app is the name of your app's root folder.
But, there's a way to fix this. And it comes directly out to Laravel's documentation.
Solution (TL;DR)
In order to use a custom mix base URL, you would require to update your config\app.php file to add the following configuration value for setting the mix URL:
'mix_url' => env('MIX_ASSET_URL', 'localhost'),
With your mix_url config option set in your app.php file, you should now be able to manipulate it by adding the MIX_ASSET_URL key in your .env file and setting it to blank, so that it points to \public\js\app.js and \public\css\app.css respectively, within your project directory.
MIX_ASSET_URL=""
That solved it for me. Hope it does it for your too. Lemme know how it goes. Cheers!
Try running npm install and after that build the assets, either npm run dev or npm run watch , depends on what you are using.
In my case,
laravel 9
I should have changed the mix-manifest.json file
"/js/application.js": "/js/application.js",
"/js/admin.js": "/js/admin.js",
"/css/application.css": "/css/application.css",
"/css/admin.css":"/css/admin.css"
Delete package-lock.json.
Delete folder 'node_modules' and run 'npm install' to reinstall all modules.
Then run 'npm run watch' or 'npm run production'.
That helps me to fix that problem.
check the package.json file for the command to build the scripts and styles, normally you will have by default: npm run dev. Might happen that you will need to run:
npm rebuild node-sass
npm run dev or npm run watch
I changed my webpack.mix.js files and made these changes there and worked. Only define the specific path to public/js/app.js in webpack.mix.js
mix.js(
[
"resources/assets/js/jquery.js",
"resources/assets/js/popper.js",
"resources/js/app.js",
],
"public/js/app.js"
)
.autoload({
jquery: ["jquery", "jQuery", "$", "window.jQuery"],
Popper: ["popper", "Popper", "popper.js"],
popper: ["Popper", "popper.js"],
})
.vue()
.postCss("resources/css/app.css", "public/css", [])
.sass("resources/sass/app.scss", "public/css")
.disableNotifications(); // to disable notifications of building app;
In My case, I change
'debug' => false, to true
in the file app.config under config folder in my project to see log in my browser. Then when I run my project got error above like you. then I change to
'debug' => false again. It works.
I recently inherited a project based on the laravel framework, which after I have set up, installed all requirements by composer and run php artisan migrations on, will not run via php artisan serve.
When I researched possible causes for this, I came across the following on SO:
laravel5: chdir(): No such file or directory (errno 2)
Using artisan serve after changing the public folder name
When I follow the suggested solution in the second one of adding the lines
'''
$app = new Illuminate\Foundation\Application(
realpath(DIR . '/../')
);
'''
to bootstrap/app.php I get the same exact error.
Is there a configuration file somewhere I need to update? Most of the suggested solutions I've found like changing files under vendor seem to be rather hacky? I'm really stuck on this and any help would be greatly appreciated - thanks!
check the configuration of your Homestead.yalm folder, there you can specity where your project is in the folders->map section.
It may the error from composer so try
Composer dump-autoload -o
I am trying to use Xethron/migrations-generator in a Laravel 5.4 project in order to generate migration files for all of the tables in my database. I followed the instructions in the README file for Laravel 5 to the letter. After resolving a complaint or two (had to install php7.0-xml extension), I try to run it but it spits out an error like so:
$ php artisan migrate:generate
Using connection: mysql
Generating migrations for: group_product_assoc, groups, product_hierarchy_assoc, product_product_assoc, products, replist, sessionsOLD, stores, tree, users, zipcode_coordinates
Do you want to log these migrations in the migrations table? [Y/n] :
> n
Setting up Tables and Index Migrations
[Way\Generators\Filesystem\FileNotFound]
/var/www/my-project/vendor/way/generators/src/Way/Generators/templates/migration.txt
I have reported this issue to Xethron on github and apparently I'm not the only person having this problem.
Can anyone tell me how to get this working? I'm not especially fluent with Laravel or Composer so please don't skimp on the basic explanations. I'm using:
Ubuntu 16.04
PHP 7.0.15
Laravel 5.4
I had the same issue. You need to copy the following file to the location:
https://github.com/Xethron/Laravel-4-Generators/tree/master/src/Way/Generators/templates/migration.txt
In to this folder ( it's possible, this does not exist - so you can either create the folders OR change the configuration file (config.php) in vendor Xethron
/var/www/my-project/vendor/way/generators/src/Way/Generators/templates/
J. Doe's answer is essentially correct as far as I can tell. I am posting a more complete solution here to describe the exact steps I took to fix the issue.
Apparently, there's something wrong with the Xethron code in that it tries to refer to a PHP template file that is somehow not properly included/required by the Xethron package. My short-term solution seems to have worked. That solution is to first cd into the working directory:
cd /var/www/my-project
then create the directory where the file should be:
mkdir -p vendor/way/generators/src/Way/Generators/templates
then we put the template file in there in one of two ways. One way, as suggested by J. Doe is to download the file from github (https://raw.githubusercontent.com/Xethron/Laravel-4-Generators/master/src/Way/Generators/templates/migration.txt) and save it as migration.txt in the directory we just created above. Or you can cd into the working directory and execute this command:
curl https://raw.githubusercontent.com/Xethron/Laravel-4-Generators/master/src/Way/Generators/templates/migration.txt > vendor/way/generators/src/Way/Generators/templates/migration.txt
The other way is to copy the template file which is apparently in a subdirectory of the xethron package:
cp vendor/xethron/laravel-4-generators/src/Way/Generators/templates/migration.txt vendor/way/generators/src/Way/Generators/templates/migration.txt
Once the file exists in that location, You should be able to run the command again without a hitch:
php artisan migrate:generate
This issue has been resolved, simply run composer update to get the latest version.
Apologies for the inconvenience.
I know there is bunch of answer out there and none of them solved my problem. I am giving a try again in 2016 may be some one can help.
php artisan make:migration createxxxtable
don't show any error and it don't create the file
neither of these function output anything too.
php artisan list
php artisan help migrate
Its not new project. I had been working on this project earlier and it was working fine. Created bunch of migration.
I tried deleting everying inside vendor and do composer install and composer update still no luck.
I did tried command like dump-autoload , optimize , clear-compiled etc. too
Thanks
Ok found the solution. I don't know whats the reason. But it was because I was using url() helper in a custom config file i created in config folder. The config file and value of url and others works fine all across the website but it just break artisan command. I don't know why.
Removing that url() helper from my custom config file solved the problem.
Normally when this issue arises it's due to an error in your code. Check for these coporates
Could be a typo in your .env file
Could be a syntax error in your .env
Entering in wrong configuration(syntax error) in your config folder
can you please try php artisan does that open up the artisan commands?
If these doesn't show anything then check your path to project in console.
I have installed Lavarel on my ubuntu system by going through this link. After all the steps I can see the laravel default page(You have arrived). I came to know about the laravel command tool. So inside laravel folder from command tool(terminal) I tried
php artisan serve
and it showed me like this
Laravel development server started on http://localhost:8000
Directory does not exist.
When I used http://localhost:8000 from the browser it showed me like This webpage is not available. So can someone tell me how to solve this? Any help and suggestions will be really appreciable. Thanks
This is caused when Laravel cannot find public/index.php. You might need to update boostrap/paths.php to reflect your current public path.
In bootstrap/paths.php, change
'public' => __DIR__.'/public',
to
'public' => __DIR__.'/../',
*(Assuming there's a good reason for butchering the base install, such as deploying on IIS)
Reinstall it and skip the part when you remove public folder. It's a good security feature to have your public folder separated from your application code.