运行.EJS文件时,我会一直遇到错误,是我的代码中的错误还是程序中的其他位置?我该如何解决?

发布于 2025-02-10 19:26:16 字数 4419 浏览 1 评论 0原文

我正在尝试在Linux计算机上安装一个程序,该程序像网站一样在我的浏览器中使用控制面板运行,我遵循了多个教程1:1,所以我怀疑有任何错误,但是当我运行该程序时,我会继续得到一个错误(有关错误,请参见下面的代码),我不确定该错误是否在代码中,或者是否在安装中(因为我在NPM安装命令中遇到问题,因为它一直在说关键问题,运行NPM Update -Force或其他内容沿着这些方式)任何建议都将不胜感激,谢谢。

<!DOCTYPE html>
<html>

<% include partials/head.ejs %>


<body>
    <style type="text/css">
        body {
            background: #dbdbdb;
            background: -webkit-linear-gradient(to bottom right, #86fde8, #acb6e5);
            background: linear-gradient(to bottom right, #86fde8, #acb6e5);
        }

        body>.grid {
            height: 100%;
        }

        .image {
            margin-top: -100px;
        }

        .column {
            max-width: 450px;
        }
    </style>
    <script>
        $(document).ready(function () {
            $('.ui.form').form({
                fields: {
                    email: {
                        identifier: 'username',
                        rules: [
                            {
                                type: 'empty',
                                prompt: 'Please enter your username'
                            }
                        ]
                    },
                    password: {
                        identifier: 'password',
                        rules: [
                            {
                                type: 'empty',
                                prompt: 'Please enter your password'
                            }
                        ]
                    }
                }
            });
        });
    </script>

    <div class="ui middle aligned center aligned grid">

        <div class="column">

            <form class="ui large form" method="POST">
                <div class="ui stacked segment">
                    <h2 class="ui image header">
                        <div class="content">
                            <img src="/logo.png" style="height: 70px;">
                        </div>
                    </h2>
                    <div class="field">
                        <div class="ui left icon input">
                            <i class="user icon"></i>
                            <input type="text" name="username" placeholder="Username">
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui left icon input">
                            <i class="lock icon"></i>
                            <input type="password" name="password" placeholder="Password">
                        </div>
                    </div>
                    <div class="ui fluid large teal submit button">Login</div>
                    <div class="ui error message"></div>

                </div>

            </form>
            <% include partials/footer.ejs %>
        </div>
    </div>
</body>

</html>

我在浏览器中会出现以下错误

SyntaxError: Unexpected identifier in /home/kali/Downloads/L3MON-v1.1.2/assets/views/login.ejs while compiling ejs

If the above error is not helpful, you may want to try EJS-Lint:
https://github.com/RyanZim/EJS-Lint
Or, if you meant to create an async function, pass `async: true` as an option.
    at new Function (<anonymous>)
    at Template.compile (/home/kali/Downloads/L3MON-v1.1.2/node_modules/ejs/lib/ejs.js:673:12)
    at Object.compile (/home/kali/Downloads/L3MON-v1.1.2/node_modules/ejs/lib/ejs.js:398:16)
    at handleCache (/home/kali/Downloads/L3MON-v1.1.2/node_modules/ejs/lib/ejs.js:235:18)
    at tryHandleCache (/home/kali/Downloads/L3MON-v1.1.2/node_modules/ejs/lib/ejs.js:274:16)
    at View.exports.renderFile [as engine] (/home/kali/Downloads/L3MON-v1.1.2/node_modules/ejs/lib/ejs.js:491:10)
    at View.render (/home/kali/Downloads/L3MON-v1.1.2/node_modules/express/lib/view.js:135:8)
    at tryRender (/home/kali/Downloads/L3MON-v1.1.2/node_modules/express/lib/application.js:640:10)
    at Function.render (/home/kali/Downloads/L3MON-v1.1.2/node_modules/express/lib/application.js:592:3)
    at ServerResponse.render (/home/kali/Downloads/L3MON-v1.1.2/node_modules/express/lib/response.js:1012:7)

是代码中的错误,还是程序中的其他错误?

I am trying to install a program on my Linux machine that runs like a website in my browser with a control panel, I followed multiple tutorials 1:1 so I doubt there are any mistakes, but when I run the program, I keep getting an error (see code below for error) I'm not sure if the error is in the code, or if it's in the installation (since I had problems with npm install commands as it kept saying critical problems, run npm update -force or something along these lines) any advice would be appreciated, thank you in advance.

<!DOCTYPE html>
<html>

<% include partials/head.ejs %>


<body>
    <style type="text/css">
        body {
            background: #dbdbdb;
            background: -webkit-linear-gradient(to bottom right, #86fde8, #acb6e5);
            background: linear-gradient(to bottom right, #86fde8, #acb6e5);
        }

        body>.grid {
            height: 100%;
        }

        .image {
            margin-top: -100px;
        }

        .column {
            max-width: 450px;
        }
    </style>
    <script>
        $(document).ready(function () {
            $('.ui.form').form({
                fields: {
                    email: {
                        identifier: 'username',
                        rules: [
                            {
                                type: 'empty',
                                prompt: 'Please enter your username'
                            }
                        ]
                    },
                    password: {
                        identifier: 'password',
                        rules: [
                            {
                                type: 'empty',
                                prompt: 'Please enter your password'
                            }
                        ]
                    }
                }
            });
        });
    </script>

    <div class="ui middle aligned center aligned grid">

        <div class="column">

            <form class="ui large form" method="POST">
                <div class="ui stacked segment">
                    <h2 class="ui image header">
                        <div class="content">
                            <img src="/logo.png" style="height: 70px;">
                        </div>
                    </h2>
                    <div class="field">
                        <div class="ui left icon input">
                            <i class="user icon"></i>
                            <input type="text" name="username" placeholder="Username">
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui left icon input">
                            <i class="lock icon"></i>
                            <input type="password" name="password" placeholder="Password">
                        </div>
                    </div>
                    <div class="ui fluid large teal submit button">Login</div>
                    <div class="ui error message"></div>

                </div>

            </form>
            <% include partials/footer.ejs %>
        </div>
    </div>
</body>

</html>

I get the following error in my browser

SyntaxError: Unexpected identifier in /home/kali/Downloads/L3MON-v1.1.2/assets/views/login.ejs while compiling ejs

If the above error is not helpful, you may want to try EJS-Lint:
https://github.com/RyanZim/EJS-Lint
Or, if you meant to create an async function, pass `async: true` as an option.
    at new Function (<anonymous>)
    at Template.compile (/home/kali/Downloads/L3MON-v1.1.2/node_modules/ejs/lib/ejs.js:673:12)
    at Object.compile (/home/kali/Downloads/L3MON-v1.1.2/node_modules/ejs/lib/ejs.js:398:16)
    at handleCache (/home/kali/Downloads/L3MON-v1.1.2/node_modules/ejs/lib/ejs.js:235:18)
    at tryHandleCache (/home/kali/Downloads/L3MON-v1.1.2/node_modules/ejs/lib/ejs.js:274:16)
    at View.exports.renderFile [as engine] (/home/kali/Downloads/L3MON-v1.1.2/node_modules/ejs/lib/ejs.js:491:10)
    at View.render (/home/kali/Downloads/L3MON-v1.1.2/node_modules/express/lib/view.js:135:8)
    at tryRender (/home/kali/Downloads/L3MON-v1.1.2/node_modules/express/lib/application.js:640:10)
    at Function.render (/home/kali/Downloads/L3MON-v1.1.2/node_modules/express/lib/application.js:592:3)
    at ServerResponse.render (/home/kali/Downloads/L3MON-v1.1.2/node_modules/express/lib/response.js:1012:7)

Is my error in the code, or is it somewhere else in the program?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

摘星┃星的人 2025-02-17 19:26:16

替换第4行

&lt;%包括partials/head.ejs%&gt; with&lt;% - 包括('partials/head.ejs'); %&gt;

和83

&lt;%包括partials/footer.ejs%&gt; with&lt;% - 包括('partials/footer.ejs'); %&gt;

Replace line 4

<% include partials/head.ejs %> with <%- include('partials/head.ejs'); %>

and line 83

<% include partials/footer.ejs %> with <%- include('partials/footer.ejs'); %>

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