[英]Error: ENOENT: no such file or directory, stat Laravel mix bug
I have a tiered folder structure with stylesheets and script files.我有一个包含样式表和脚本文件的分层文件夹结构。 I need to keep the same structure in the output folder.我需要在输出文件夹中保持相同的结构。 For all scripts and styles, I get an array of paths, convert them and give them to the mix.对于所有脚本和样式,我得到一组路径,转换它们并将它们混合。
The problem is that the mix accepts my paths but doesn't create the desired structure.问题是混合接受了我的路径但没有创建所需的结构。 Previously I did the array of paths manually, now I am not getting the right one.以前我手动做了路径数组,现在我没有得到正确的路径。 There are no compiler errors.没有编译器错误。 I still use mix.js(str, str2)
and mix.less(str, str2)
我仍然使用mix.js(str, str2)
和mix.less(str, str2)
The paths I received are similar to those that I wrote manually我收到的路径和我手动写的类似
But if I start the nodejs debugging process, then I will see但是如果我启动 nodejs 调试过程,那么我会看到
My folder structure我的文件夹结构
My array of js paths我的js路径数组
Less array the same as js Less array 和js一样
i still dont get my files, but debug error is disappear我仍然没有得到我的文件,但调试错误消失了
let compileJS = (str, str2) => { console.log(str,str2) mix.js(str, str2); }; glob("./components/**/*.js", (err, files) => { files.map((p) => { pathsJS.push({ in: p, out: p.replace("./components/", "./dist/views/"), }); }); // console.log(pathsJS); pathsJS.map((p) => { compileJS(p.in, p.out); }); });
The problem was that all libraries by default make the issuance of paths an asynchronous method.问题是默认情况下所有库都将路径发布作为异步方法。 Mix works synchronously. Mix 同步工作。 I installed a faster version of the plugin, did the output of paths with synchronous and placed the mix function in the same function.我安装了一个更快版本的插件,同步输出路径并将混合函数放在同一个函数中。 Thus, the code is executed at once.因此,代码立即执行。
const glob = require("fast-glob"); let compile = () => { function getFilesJS(baseSrc) { return glob.sync("./components/**/*.js", { onlyFiles: true, }); } let filesjs = getFilesJS(); filesjs.map((p) => { pathsJS.push({ in: p, out: p.replace("./components/", "./dist/views/"), }); }); pathsJS.map((p) => { mix.js(p.in, p.out); }); function getFilesLESS() { return glob.sync("./components/**/*.less", { onlyFiles: true, }); } let filesless = getFilesLESS(); filesless.map((p) => { pathsLess.push({ in: p, out: p.replace("./components/", "./dist/views/"), }); }); pathsLess.map((p) => { mix.less(p.in, p.out.replace("style.less", "")); }); mix.less("./src/less/styles.less", "./dist/template_styles.css"); mix.js("./src/js/script.js", "./dist/script.js"); };
In my case there was two bugs with nodejs and broken symlink to storage (after moving project folder into other place) (laravel 8).在我的例子中,有两个 nodejs 错误和损坏的存储符号链接(将项目文件夹移动到其他地方后)(laravel 8)。 So what i've done:所以我做了什么:
php artisan storage:link
删除了存储符号链接和php artisan storage:link
$ node -v
18.12.1
$ n 14.21.2
installed
$ node -v
14.21.2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.