laravel 未捕获的异常:无法找到 Mix 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51191510/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:52:29  来源:igfitidea点击:

Uncaught Exception: Unable to locate Mix file

phplaravelwebpack

提问by CR7

I am trying to run a laravel app in my local system. I have followed the https://gist.github.com/hootlex/da59b91c628a6688ceb1link. I run the command php artisan servecommand, and when I browse it, then produces the error

我正在尝试在本地系统中运行 Laravel 应用程序。我已经关注了https://gist.github.com/hootlex/da59b91c628a6688ceb1链接。我运行命令php artisan serve命令,当我浏览它时,会产生错误

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

在helpers.php的指定行,它有

 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

公共/混合-manifest.json

{
  "/mix.js": "/mix.js"
}

I couldn't sort it out. Please help. Thanks

我无法解决它。请帮忙。谢谢

回答by Adre Astrian

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.

您正在加载的刀片文件显然有mix('/css/vendor.css')调用。您可以注释掉这一行或安装 npm 然后构建您的资产。

Your manifest file doesn't have /css/vendor.cssbut 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.

您的清单文件没有,/css/vendor.css但是如果您检查刀片文件 ( views),您会发现您正在调用mix('/css/vendor.css'). 因此,如果您找到并注释掉这一行,您的问题将得到解决。

Ideally, mix()is used for loading assets that were built by webpack. It will then take care of the versioning string for you. How mixcan be used is detailed in the documentation. I will refrain myself from discussing that here.

理想情况下,mix()用于加载由 webpack 构建的资产。然后它会为您处理版本控制字符串。文档中详细说明了如何使用混合。我将避免在这里讨论这个问题。

You've built your assets by running npm run devor similar commands. And then the manifest file doesn't contain those assets mapping. And your publicdirectory doesn't have those assets as well. Then it's safe to assume that you can remove those mixcalls from your blade (views) files.

您已经通过运行npm run dev或类似的命令构建了您的资产。然后清单文件不包含这些资产映射。而且您的public目录也没有这些资产。然后可以安全地假设您可以mix从刀片 ( views) 文件中删除这些调用。

If you have the assets built in your publicdirectory then you can load those assets by assetsfunction.

如果您的public目录中内置了资产,那么您可以按assets功能加载这些资产。

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.

最后,您应该先了解您的资产,然后再将它们加载到您的网站。我的想法是您不知道这些资产的来源,因此您不应该首先加载它们。

回答by Armin

Try running npm installand after that build the assets, either npm run devor npm run watch, depends on what you are using.

尝试运行npm install,然后构建资产,npm run devnpm run watch取决于您使用的内容。

回答by Ilir Hushi

check the package.jsonfile 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:

检查package.json用于构建脚本和样式的命令的文件,通常默认情况下您将拥有:npm run dev. 可能会发生您需要运行的情况:

  • npm rebuild node-sass
  • npm run devor npm run watch
  • npm rebuild node-sass
  • npm run dev或者 npm run watch