Laravel Jetstream:关键依赖性:不支持访问Import.Meta(仅支持属性访问)

发布于 2025-02-13 19:33:58 字数 2517 浏览 0 评论 0原文

在使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我最亲爱的 2025-02-20 19:34:09

尝试安装Laravel-Vite-Plugin:

首先使用此命令安装Laravel-Vite插件。

npm install --save-dev vite laravel-vite-plugin
npm install --save-dev @vitejs/plugin-vue

然后您需要执行以下命令。

npm install
  
npm run dev
php artisan migrate

,现在,您的错误必须解决

Try to install laravel-vite-plugin:

First of install the laravel-vite plugin just using this command.

npm install --save-dev vite laravel-vite-plugin
npm install --save-dev @vitejs/plugin-vue

Then you need to execute the following command.

npm install
  
npm run dev
php artisan migrate

and Now, your error must be solved

メ斷腸人バ 2025-02-20 19:34:07

先生,如果您有 php版本< 8 laravel版本< 9 然后将 PHP版本更新为8 laravel版本为9 。它将解决您的问题。

检查Laravel Verion Run:
php工匠 - version

检查PHP版本运行: php -version

请检查在官方网站上的Laravel的支持政策

Sir, if you have PHP version < 8 and Laravel version < 9 then update the PHP version to 8 and Laravel version to 9. It will fix your problem.

To check Laravel verion run:
php artisan --version

To check PHP version run: php --version

Please check Support Policy of laravel on official site.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文