php Mix 清单在它确实存在时不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45153738/
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
The Mix manifest does not exist when it does exist
提问by Chris
For my admin panel I extract all the assets including the manifest-json.jsto mix.setPublicPath(path.normalize('public/backend/')).
对于我的管理面板,我提取了所有资产,包括manifest-json.jsto mix.setPublicPath(path.normalize('public/backend/'))。
All the files get correctly added to the backend folder, and the manifest-json.jsfile looks as follows:
所有文件都正确添加到后端文件夹,manifest-json.js文件如下所示:
{
// all correct here
"/js/vendor.js": "/js/vendor.js",
"/js/app.js": "/js/app.js",
"/css/app.css": "/css/app.css",
"/js/manifest.js": "/js/manifest.js"
}
the problem is that when using
问题是当使用
{{ mix('backend/css/app.css') }}
in my blade-files, it looks in public/manifest-json.jsinstead of looking for it in backend/manifest-json.js.
在我的刀片文件中,它查找public/manifest-json.js而不是在backend/manifest-json.js.
How can I make sure the right manifest-json.jsfile is used?
如何确保使用正确的manifest-json.js文件?
采纳答案by Chris
The problem I faced was that the mix()-helper function by default looks for the manifest-json file in /public/manifest-json.jsso if you store that file on any other directory level then it will throw that error.
我面临的问题是mix()-helper 函数默认会在其中查找 manifest-json 文件,/public/manifest-json.js因此如果您将该文件存储在任何其他目录级别,则会引发该错误。
Let's say the manifest-json file is stored in public/app/manifest-json.js, then for a file located in public/app/css/app.cssyou would use:
假设 manifest-json 文件存储在 中public/app/manifest-json.js,那么对于位于中的文件,public/app/css/app.css您将使用:
<link rel="stylesheet" href="{{ mix('css/app.css', 'app') }}">
The mix()-helper function allows for a second argument, the directory of the manifest file. Just specify it there and it will use the correct manifest file.
该mix()-helper功能允许第二个参数,清单文件的目录。只需在那里指定它,它就会使用正确的清单文件。
回答by
i solved my problem running this command
我解决了运行此命令的问题
npm install
and then
进而
npm run production
Thank You.
谢谢你。
回答by Gvep
I had same exception after deployment laravelproject to server. It was working perfectly fine on localhost but after lot of research I found a solution. If you encounter this exception on server then you have to bind your publicpath to public_html
将laravel项目部署到服务器后,我遇到了同样的异常 。它在本地主机上运行良好,但经过大量研究后,我找到了解决方案。如果您在服务器上遇到此异常,则必须将公共路径绑定到public_html
Just go to under the app/Providers, you will find your AppServiceProviderfile and inside boot()method make the binding as below.
只需转到 app/Providers 下,您将找到您的AppServiceProvider文件,并在boot()方法中进行如下绑定。
$this->app->bind('path.public', function() {
return base_path().'/../public_html';
});
回答by Solivan
In shared hostsand laravel 5.6tested:
after doing standard levels such as explained here;
two levels needed:
in app/Providers/AppServiceProvider.php:
在共享主机和Laravel 5.6 中测试:在执行标准级别后,如解释here;需要两个级别:在app/Providers/AppServiceProvider.php:
$this->app->bind('path.public', function() {
return realpath(base_path().'/../public_html');
});
and in public_htmlfile make .htaccessfile with content:
并在public_html文件中生成.htaccess包含内容的文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
source: herethis file most change for some situations.
来源:这里这个文件在某些情况下变化最大。
that's all and solved my problem
这就是全部并解决了我的问题
回答by Haritsinh Gohil
i have same problem as questioner: manifest does not existfor solving it what i have done is ran 2 commands as following:
我和提问者有同样的问题:manifest does not exist为了解决它,我所做的是运行 2 个命令,如下所示:
npm install
and then
进而
npm run dev
and the error is solved now. yippi.
现在错误已解决。伊皮。
回答by Denes Papp
I had the same issue with a Laravel package, its assets were not published:
我在 Laravel 包中遇到了同样的问题,它的资产没有发布:
This solved the issue for me:
这为我解决了这个问题:
php artisan vendor:publish --tag=telescope-assets --force
php artisan vendor:publish --tag=telescope-assets --force
Sources: https://github.com/laravel/telescope/issues/136https://github.com/laravel/telescope/issues/250
来源:https: //github.com/laravel/telescope/issues/136 https://github.com/laravel/telescope/issues/250
回答by Fakhri Ramadhan
I found new solution
我找到了新的解决方案
The problem is mix manifest right? So just redirect to the mix manifest feature. for example, you have:
问题是混合清单对吗?所以只需重定向到混合清单功能。例如,您有:
{{ style(mix('css/backend.css')) }}
just change your code into
只需将您的代码更改为
{{ style('css/backend.css') }}
it works for me
这个对我有用
回答by Aagiidu
I had the issue on a shared host, where I was not able to run npm commands. Then I used the simplest way. In the /vendor/laravel/.../Foundation/Mix.php replace
我在共享主机上遇到了问题,在那里我无法运行 npm 命令。然后我用了最简单的方法。在/vendor/laravel/.../Foundation/Mix.php 中替换
i$manifests[$manifestPath] = json_decode(file_get_contents($manifestPath), true);
to
到
$manifests[$manifestPath] = json_decode(file_get_contents('https://your-domain.com/mix-manifest.json'), true);
Not recommended, but it works. You can use it as your last try.
不推荐,但它有效。您可以将其用作最后一次尝试。

