Laravel Jetstream:关键依赖性:不支持访问Import.Meta(仅支持属性访问)
在使用Jetstream安装Laravel惯性时,我面临着这个关键错误。
larevel new projectName --jet
然后我明白了:
警告.//resources/js/app.js 16:65-76关键依赖性: 直接访问import.meta是不支持的(只有属性访问是 支持) WebPack用1个警告
编译
,我只能在浏览器[1]中看到@vite('resources/js/app.js'): https://i.sstatic.net/wjqct.png
资源/js/app.js
import "./bootstrap";
import "../css/app.css";
import { createApp, h } from "vue";
import { createInertiaApp } from "@inertiajs/inertia-vue3";
import { InertiaProgress } from "@inertiajs/progress";
import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers";
import { ZiggyVue } from "../../vendor/tightenco/ziggy/dist/vue.m";
const appName =
window.document.getElementsByTagName("title")[0]?.innerText || "Laravel";
createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) =>
resolvePageComponent(
`./Pages/${name}.vue`,
import.meta.glob("./Pages/**/*.vue")
),
setup({ el, app, props, plugin }) {
return createApp({ render: () => h(app, props) })
.use(plugin)
.use(ZiggyVue, Ziggy)
.mount(el);
},
});
InertiaProgress.init({ color: "#4B5563" });
package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"@inertiajs/inertia": "^0.11.0",
"@inertiajs/inertia-vue3": "^0.6.0",
"@inertiajs/progress": "^0.2.7",
"@tailwindcss/forms": "^0.5.2",
"@tailwindcss/typography": "^0.5.2",
"@vitejs/plugin-vue": "^2.3.3",
"autoprefixer": "^10.4.7",
"axios": "^0.21",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"postcss": "^8.4.14",
"tailwindcss": "^3.1.0",
"vue": "^3.2.31"
}
}
webpack.config.js
const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
//
]);
我看不到默认的laravel布局视图或登录/注册视图。
I am facing this critical error while installing Laravel Inertia with Jetstream.
larevel new projectName --jet
Then I get this:
WARNING in ./resources/js/app.js 16:65-76 Critical dependency:
Accessing import.meta directly is unsupported (only property access is
supported)
webpack compiled with 1 warning
When I run the project, i can see only @vite('resources/js/app.js') in the browser[1]: https://i.sstatic.net/WjQct.png
resources/js/app.js
import "./bootstrap";
import "../css/app.css";
import { createApp, h } from "vue";
import { createInertiaApp } from "@inertiajs/inertia-vue3";
import { InertiaProgress } from "@inertiajs/progress";
import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers";
import { ZiggyVue } from "../../vendor/tightenco/ziggy/dist/vue.m";
const appName =
window.document.getElementsByTagName("title")[0]?.innerText || "Laravel";
createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) =>
resolvePageComponent(
`./Pages/${name}.vue`,
import.meta.glob("./Pages/**/*.vue")
),
setup({ el, app, props, plugin }) {
return createApp({ render: () => h(app, props) })
.use(plugin)
.use(ZiggyVue, Ziggy)
.mount(el);
},
});
InertiaProgress.init({ color: "#4B5563" });
package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"@inertiajs/inertia": "^0.11.0",
"@inertiajs/inertia-vue3": "^0.6.0",
"@inertiajs/progress": "^0.2.7",
"@tailwindcss/forms": "^0.5.2",
"@tailwindcss/typography": "^0.5.2",
"@vitejs/plugin-vue": "^2.3.3",
"autoprefixer": "^10.4.7",
"axios": "^0.21",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"postcss": "^8.4.14",
"tailwindcss": "^3.1.0",
"vue": "^3.2.31"
}
}
webpack.config.js
const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
//
]);
I can't see the default Laravel layout view or the login/register views.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试安装Laravel-Vite-Plugin:
首先使用此命令安装Laravel-Vite插件。
然后您需要执行以下命令。
,现在,您的错误必须解决
Try to install laravel-vite-plugin:
First of install the laravel-vite plugin just using this command.
Then you need to execute the following command.
and Now, your error must be solved
先生,如果您有
php版本< 8
和laravel版本< 9
然后将PHP版本更新为8
和laravel版本为9
。它将解决您的问题。请检查在官方网站上的Laravel的支持政策。
Sir, if you have
PHP version < 8
andLaravel version < 9
then update thePHP version to 8
andLaravel version to 9
. It will fix your problem.Please check Support Policy of laravel on official site.